Hello,
I have a problem with the SfDataGrid control. First of all Visual Studio is not able to generate a template by clicking in the context menu on the control: edit template -> edit copy. VS does not do anything. For other controls this functionality works. I borrowed the template of this control from another project generated by you. And here starts another problem. When I want to create my control based on SfDataGrid compilation ends with an error:
I assume that I have all required packages:
What am I doing wrong? Best regards.
Below is my code:
<Style TargetType="{x:Type local:SfDataGridExt}">
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="Gray" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="FontSize" Value="12" />
<Setter Property="FontFamily" Value="Segoe UI" />
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto" />
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
<Setter Property="ScrollViewer.PanningMode" Value="Both" />
<Setter Property="ScrollViewer.PanningRatio" Value="1" />
<Setter Property="ScrollViewer.IsDeferredScrollingEnabled" Value="False" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:SfDataGridExt}">
<Grid SnapsToDevicePixels="True">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Busy">
<Storyboard>
<BooleanAnimationUsingKeyFrames Storyboard.TargetName="PART_BusyDecorator" Storyboard.TargetProperty="IsBusyIndicatorShowing">
<DiscreteBooleanKeyFrame KeyTime="0" Value="True" />
</BooleanAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Normal" />
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Border Grid.Row="0"
SnapsToDevicePixels="True"
Visibility="{Binding Path=ShowGroupDropArea,
RelativeSource={RelativeSource TemplatedParent},
Converter={StaticResource VisiblityConverter}}">
<syncfusion:GroupDropArea x:Name="PART_GroupDropArea" SnapsToDevicePixels="True" />
</Border>
<Border Grid.Row="1"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
SnapsToDevicePixels="True">
<ScrollViewer x:Name="PART_ScrollViewer"
CanContentScroll="True"
FlowDirection="{TemplateBinding FlowDirection}"
HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
IsDeferredScrollingEnabled="{TemplateBinding ScrollViewer.IsDeferredScrollingEnabled}"
IsTabStop="False"
PanningMode="{TemplateBinding ScrollViewer.PanningMode}"
PanningRatio="{TemplateBinding ScrollViewer.PanningRatio}"
VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}">
<syncfusion:VisualContainer x:Name="PART_VisualContainer" />
</ScrollViewer>
</Border>
<syncfusion:BusyDecorator x:Name="PART_BusyDecorator"
Grid.Row="1"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Style>
</Setter>
</Style>
Hi Rob,
Based on the provided information, we have checked the reported issue in our
end. The reference for VisiblityConverter is not available and we have to
include the mentioned converter class which is present in Syncfusion name space
like below,
Xaml :
Namespace :
|
xmlns:syncfusion=http://schemas.syncfusion.com/wpf |
Converter reference :
|
<syncfusion:BoolToVisiblityConverter x:Key="VisiblityConverter" /> |
We had prepared the sample based on provided information. Please check this and
revert us if you need further assistance for this.
Regards,
Dhanasekar M.
Thank you for your quick reply. Unfortunately I had the above reference in my code, but I only pasted the Style related part and this reference was over. However, in your project it works, but not completely. When I want to use 2 times the same control it gives an error that the PropertyMetadata object is already registered for the type "SfDataGridExt". I don't understand why - it is possible that I am missing something because I am not an expert in creating controls :)
Best regards
Robert
Hi Rob,
We ca able to reproduce the reported issue in our end. We will validate and update you the details on April 28, 2022.
We appreciate your patience until then.
Regards,
Dhanasekar M.
Hi Rob,
We analyzed the reported issue in our end. In that you are overriding the
default style with its key inside the custom class constructor. It’s not needed
to apply the style for custom datagrid. Without this the applied styles are
reflected properly. We have modified the sample based on your scenario please
check this and revert us if you need further assistance for this.
Regards,
Dhanasekar M.
Hello Dhanasekar ,
You're 100 percent right. I have always made my controls overriden the style of basic types like Control or ContentControl etc. Now it works great. Thank you and your team for your time and help in solving the problem.
Best regards,
Robert
Hi Rob,
We are glad to
know that the provided solution satisfies your requirement.
Regards,
Dhanasekar M.