Templates and inheritance

Posted by mariusz on Stack Overflow See other posts from Stack Overflow or by mariusz
Published on 2010-06-16T14:38:04Z Indexed on 2010/06/16 14:42 UTC
Read the original article Hit count: 313

Filed under:

Hello, I have a big problem. I use additional controls for Wpf. One of them is Telerik RadWindow This control is already templated. Now I want to create custom Window with will inherit from RadWindow, and make custom template, eg. One base window will contains grid and two buttons, second base window will contain two grids (master - detail). The problem is that templates do not support inheritance. Perhaps is another way to template only the content of Winodow?

My code, that doesn't work (empty window appears, so template doesn't apply)

 <Style TargetType="{x:Type local:TBaseRjWindow}">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type local:TBaseRjContent}">

                <Border Background="{TemplateBinding Background}"
                        BorderBrush="{TemplateBinding BorderBrush}"
                        BorderThickness="{TemplateBinding BorderThickness}">

                    <Grid Name="mGrid">

                        <Grid.ColumnDefinitions>
                            <ColumnDefinition   />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition   />
                            <RowDefinition  MaxHeight="40" MinHeight="30"  />

                            <RowDefinition  MaxHeight="40" MinHeight="30"  />
                            <RowDefinition  Height="Auto"     />
                            <RowDefinition  MaxHeight="40" MinHeight="30" />
                        </Grid.RowDefinitions>

                        <telerik:RadGridView Margin="10,10,10,10" Name="grid" Grid.Row="0" Grid.Column="0"      VerticalAlignment="Stretch" HorizontalAlignment="Stretch"  ScrollMode="Deferred"  AutoGenerateColumns="False"   Width="Auto"   >
                        </telerik:RadGridView>
                        <telerik:RadDataPager Grid.Row="1" Grid.Column="0"
      x:Name="radDataPager"
      PageSize="50"
      AutoEllipsisMode="None"
      DisplayMode="First, Previous, Next, Text"
      Margin="10,0,10,0"/>

                        <StackPanel Grid.Row="1" Grid.Column="0" Margin="5 5 5 5"  HorizontalAlignment="Left" Orientation="Horizontal" Height="20" Width="Auto" VerticalAlignment="Center"  >

                            <telerik:RadButton x:Name="btAdd"  Margin="5 0 5 0"   Content="Dodaj"  />
                            <telerik:RadButton x:Name="btEdit" Margin="5 0 5 0" Content="Edytuj"   />
                            <telerik:RadButton x:Name="btDelete" Margin="5 0 5 0" Content="Usun"   />
                        </StackPanel>

                        <StackPanel Name="addFields" Background="LightGray" Visibility="Collapsed" VerticalAlignment="Top"  Grid.Row="2"  Grid.Column="0" Width="Auto" Height="Auto" Orientation="Horizontal">
                            <GroupBox Header="Szczegoly" Margin="2 2 2 2" >
                                <Grid  VerticalAlignment="Top" DataContext="{Binding SelectedItem, ElementName=grid}" Name="_gAddFields" Margin="0 0 0 0"  Width="Auto" Height="Auto"  >
                                </Grid>
                            </GroupBox>
                        </StackPanel>

                        <StackPanel  Grid.Row="3" Grid.Column="0"  Margin="5 5 5 5" HorizontalAlignment="Right" Orientation="Horizontal" Height="25" Width="Auto" VerticalAlignment="Center"  >
                            <telerik:RadButton x:Name="btSave"  IsDefault="True" Width="60"  Margin="5 0 5 0" Content="Zapisz"    />
                            <telerik:RadButton x:Name="btOK" IsDefault="True"  Width="60" Margin="5 0 5 0"   Content="Akceptuj"  />
                            <telerik:RadButton x:Name="btCancel" IsCancel="True" Width="60" Margin="5 0 5 0" Content="Anuluj"    />
                        </StackPanel>
                    </Grid>

                </Border>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

Please help

© Stack Overflow or respective owner

Related posts about wpf