开发者

Templates and inheritance

开发者 https://www.devze.com 2023-01-03 12:06 出处:网络
I have a big problem. I use additional controls for Wpf. One of them is Telerik RadWindow This control is already templated.

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.ColumnDefinition开发者_JS百科s>
                        <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


You could use the ContentTemplate for the Window. It is a DataTemplate that will be used to display the Content set on the Window.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号