Hello,
I've upgraded an old wpf application to latest Telerik WPF control version... before I've defined a GridViewCommandRow that will substitute the grouping header to the 2 buttons export/print
the code is taken from a your article and it's
The template is defined here
The buttons don't appear anymore...how can I fix it
I've upgraded an old wpf application to latest Telerik WPF control version... before I've defined a GridViewCommandRow that will substitute the grouping header to the 2 buttons export/print
the code is taken from a your article and it's
public class GridViewCommandRow { public static readonly DependencyProperty IsEnabledProperty = DependencyProperty.RegisterAttached("IsEnabled", typeof (bool), typeof (GridViewCommandRow), new PropertyMetadata(false, OnIsEnabledChanged)); public GridViewCommandRow(RadGridView grid) { RadGridView = grid; CommandRow = new ContentControl(); CommandRow.SetValue(Grid.RowProperty, 0); if (ViewCommandTemplate == null) { var commandRowTemplate = Generic.GetInstance()["CommandRowTemplate"] as ControlTemplate; if (commandRowTemplate != null) ViewCommandTemplate = commandRowTemplate; } } public ControlTemplate ViewCommandTemplate { get; set; } private ContentControl CommandRow { get; set; } public RadGridView RadGridView { get; private set; } public static void SetIsEnabled(DependencyObject dependencyObject, bool enabled) { dependencyObject.SetValue(IsEnabledProperty, enabled); } public static object GetIsEnabled(DependencyObject dependencyObject) { return dependencyObject.GetValue(IsEnabledProperty); } private static void OnIsEnabledChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) { var radGridView = sender as RadGridView; if (radGridView != null) { if ((bool) e.NewValue) { // Create new GridViewCommandRow and attach RadGridView events. var commandRow = new GridViewCommandRow(radGridView); commandRow.Attach(); } } } private void Attach() { RadGridView.DataLoaded += RadGridView_DataLoaded; } private void RadGridView_DataLoaded(object sender, EventArgs e) { if (RadGridView.Items.Count > 0) { RadGridView.SelectedItem = RadGridView.Items[0]; } Grid hierarchyGrid = RadGridView.ChildrenOfType<Grid>().FirstOrDefault(c => c.Name == "HierrarchyBackground"); if (hierarchyGrid != null && CommandRow.Parent == null) { hierarchyGrid.Children.Add(CommandRow); CommandRow.Template = ViewCommandTemplate; } } }The template is defined here
<ResourceDictionary x:Class="DOME.Modules.Core.Themes.Generic" xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:conv="clr-namespace:DOME.Modules.Core.Framework.Converters" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" xmlns:Telerik_Windows_Controls_Chromes="clr-namespace:Telerik.Windows.Controls.Chromes;assembly=Telerik.Windows.Controls" xmlns:if="clr-namespace:DOME.Modules.Core" xmlns:local="clr-namespace:DOME.Modules.Core"> <ResourceDictionary.MergedDictionaries> <ResourceDictionary> <SolidColorBrush x:Key="GridView_EditIndicatorBackground1" Color="#7F848484" /> <SolidColorBrush x:Key="GridView_EditIndicatorBackground2" Color="#FFCBCBCB" /> <SolidColorBrush x:Key="GridView_EditIndicatorBackground3" Color="#FF848484" /> <SolidColorBrush x:Key="GridView_EditIndicatorBackground4" Color="#FFB6F7FD" /> <LinearGradientBrush x:Key="GridViewGroupPanelInnerBorderBrush" EndPoint="0.5,1" StartPoint="0.5,0"> <GradientStop Color="#FFEAEDF6" Offset="0" /> <GradientStop Color="#FFF2F5FA" Offset="1" /> </LinearGradientBrush> <telerik:Office_BlackTheme x:Key="Theme" /> <SolidColorBrush x:Key="ControlOuterBorder_Normal" Color="#FF848484" /> <LinearGradientBrush x:Key="ControlBackground_Normal" EndPoint="0.5,1" StartPoint="0.5,0"> <GradientStop Color="White" /> <GradientStop Color="#FFD4D4D4" Offset="1" /> <GradientStop Color="Gainsboro" Offset="0.42" /> <GradientStop Color="#FFADADAD" Offset="0.43" /> </LinearGradientBrush> <SolidColorBrush x:Key="ControlForeground_Normal" Color="#FF0E0E0E" /> <CornerRadius x:Key="ControlOuterBorder_CornerRadius">1</CornerRadius> <LinearGradientBrush x:Key="InsertBackground" EndPoint="0.5,1" StartPoint="0.5,0"> <GradientStop Color="White" /> <GradientStop Color="#FFA9E0AF" Offset="1" /> <GradientStop Color="#FFA9F7B0" Offset="0.42" /> <GradientStop Color="#FF6D8F70" Offset="0.43" /> </LinearGradientBrush> <Style x:Key="RadButtonStyle1" TargetType="telerik:RadButton"> <Setter Property="BorderThickness" Value="1" /> <Setter Property="BorderBrush" Value="{StaticResource ControlOuterBorder_Normal}" /> <Setter Property="Background" Value="{StaticResource ControlBackground_Normal}" /> <Setter Property="Foreground" Value="{StaticResource ControlForeground_Normal}" /> <Setter Property="HorizontalContentAlignment" Value="Center" /> <Setter Property="VerticalContentAlignment" Value="Center" /> <Setter Property="Padding" Value="3" /> <Setter Property="CornerRadius" Value="{StaticResource ControlOuterBorder_CornerRadius}" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="telerik:RadButton"> <Grid> <VisualStateManager.VisualStateGroups> <VisualStateGroup x:Name="CommonStates"> <VisualState x:Name="Normal" /> <VisualState x:Name="Disabled"> <Storyboard> <DoubleAnimation Duration="0" Storyboard.TargetName="Content" Storyboard.TargetProperty="Opacity" To="0.5" /> </Storyboard> </VisualState> </VisualStateGroup> </VisualStateManager.VisualStateGroups> <Telerik_Windows_Controls_Chromes:ButtonChrome x:Name="buttonChrome" BorderThickness="{Binding BorderThickness, RelativeSource={RelativeSource TemplatedParent}}" telerik:StyleManager.Theme="{StaticResource Theme}" CornerRadius="{TemplateBinding CornerRadius}" RenderEnabled="{TemplateBinding IsEnabled}" RenderFocused="{TemplateBinding IsFocused}" RenderMouseOver="{TemplateBinding IsMouseOver}" RenderNormal="{TemplateBinding IsBackgroundVisible}" RenderPressed="{TemplateBinding IsPressed}" Background="{StaticResource ControlBackground_Normal}" /> <ContentPresenter x:Name="Content" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" OpacityMask="{StaticResource InsertBackground}" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" /> </Grid> </ControlTemplate> </Setter.Value> </Setter> <Setter Property="FontWeight" Value="Normal" /> <Setter Property="FontSize" Value="13.333" /> </Style> <BooleanToVisibilityConverter x:Key="visibilityConverter"></BooleanToVisibilityConverter> <Style x:Key="FlowDocStyle" TargetType="{x:Type FlowDocumentScrollViewer}"> <Setter Property="KeyboardNavigation.TabNavigation" Value="Local" /> <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Hidden" /> <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Hidden" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type FlowDocumentScrollViewer}"> <Grid Language="en-us" Uid="Grid_26"> <Grid.Resources> <conv:HtmlToFlowDocumentConverter x:Key="htmlToXamlConverter" /> </Grid.Resources> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> </Grid.RowDefinitions> <Border CornerRadius="10" Uid="Border_49" Margin="0,0,0,0" Background="Azure"> <ScrollViewer x:Name="PART_ContentHost" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Uid="ScrollViewer_8" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Background="#FFEFF7FC" Margin="5,5,5,5" Height="Auto" Width="Auto"> </ScrollViewer> </Border> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style> <ControlTemplate x:Key="test" TargetType="{x:Type if:IFUserControl}"> <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="True"> <Grid> <Grid.Resources> <conv:HtmlToFlowDocumentConverter x:Key="htmlToXamlConverter" /> </Grid.Resources> <Grid.RowDefinitions> <RowDefinition Height="16"></RowDefinition> <RowDefinition></RowDefinition> </Grid.RowDefinitions> <StackPanel Grid.Row="0" HorizontalAlignment="Right" Orientation="Horizontal"> <Image Height="16" Width="16" x:Name="image"> <Image.Source> <BitmapImage UriSource="/DOME;component/Media/help.png"></BitmapImage> </Image.Source> </Image> <Popup IsOpen="False" x:Name="HelpMessagePopUp" AllowsTransparency="True" PopupAnimation="Fade" HorizontalOffset="-35" VerticalOffset="0"> <Grid> <Border BorderThickness="1" BorderBrush="Black" CornerRadius="10"> <FlowDocumentScrollViewer x:Name="flowdoc" Document="{Binding HelpMessage,Converter={StaticResource htmlToXamlConverter}}" Style="{StaticResource FlowDocStyle}"> </FlowDocumentScrollViewer> </Border> </Grid> </Popup> </StackPanel> <ContentPresenter Grid.Row="1" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" ContentStringFormat="{TemplateBinding ContentStringFormat}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" /> </Grid> </Border> <ControlTemplate.Triggers> <Trigger Property="IsMouseOver" Value="True" SourceName="image"> <Setter TargetName="HelpMessagePopUp" Property="IsOpen" Value="True" /> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> <ControlTemplate x:Key="CommandRowTemplate"> <StackPanel Orientation="Horizontal" Background="{StaticResource GridViewGroupPanelInnerBorderBrush}"> <telerik:RadButton Command="{Binding PrintExportModel.PrintCommand}" CommandParameter="{Binding RelativeSource= { RelativeSource AncestorType={x:Type telerik:RadGridView}}}" Width="40" Height="35" Margin="5" Style="{StaticResource RadButtonStyle1}" IsEnabled="{Binding CanPrintExport}"> <telerik:RadButton.Content> <StackPanel Orientation="Horizontal"> <Image Height="20" Width="20"> <Image.Source> <BitmapImage UriSource="/DOME;component/Media/print.png"></BitmapImage> </Image.Source> </Image> </StackPanel> </telerik:RadButton.Content> </telerik:RadButton> <telerik:RadButton Command="{Binding PrintExportModel.ExportCommand}" CommandParameter="{Binding RelativeSource= { RelativeSource AncestorType={x:Type telerik:RadGridView}}}" Width="40" Height="35" Margin="5" Style="{StaticResource RadButtonStyle1}" IsEnabled="{Binding CanPrintExport}"> <telerik:RadButton.Content> <StackPanel Orientation="Horizontal"> <Image Height="20" Width="20"> <Image.Source> <BitmapImage UriSource="/DOME;component/Media/export.png"></BitmapImage> </Image.Source> </Image> </StackPanel> </telerik:RadButton.Content> </telerik:RadButton> <telerik:RadButton Command="{Binding PrintExportModel.ExportMasterDetailCommand}" CommandParameter="{Binding RelativeSource= { RelativeSource AncestorType={x:Type telerik:RadGridView}}}" Width="40" Height="35" Margin="5" Style="{StaticResource RadButtonStyle1}" IsEnabled="{Binding CanExportMasterDetail}" Visibility="{Binding CanExportMasterDetail,Converter={StaticResource visibilityConverter}}"> <telerik:RadButton.Content> <StackPanel Orientation="Horizontal"> <Image Height="20" Width="20"> <Image.Source> <BitmapImage UriSource="/DOME;component/Media/export.png"></BitmapImage> </Image.Source> </Image> </StackPanel> </telerik:RadButton.Content> </telerik:RadButton> </StackPanel> </ControlTemplate> <x:Array Type="{x:Type telerik:RadMenuItem}" x:Key="ContextMenuCommandTemplate"> <telerik:RadMenuItem Header="Expand all" CommandParameter="expand_all" /> <!-- x:Name="expand"--> <telerik:RadMenuItem Header="Collapse all" CommandParameter="collapse_all" /> <!--x:Name="collapse" --> </x:Array> </ResourceDictionary> <ResourceDictionary Source="MyDictionary.xaml" /> </ResourceDictionary.MergedDictionaries></ResourceDictionary>The buttons don't appear anymore...how can I fix it