Hello,
I am using User Control derived from the Xceed Grid. I want the style to be given dynamically for the Xceed DataCell. I dont want to give the xaml but want to add style in the .cs file dynamically.
The code for the xaml for adding the style for xceed data cell:
<Grid Name="gd">
<Grid.Resources>
<Style TargetType="{x:Type xcdg:DataCell}">
<Setter Property="HorizontalContentAlignment" Value="Right"/>
</Style>
</Grid.Resources>
</Grid>
I am getting the desired output but for some DataCell i want the Alignment as Left which i may get using the Data Trigger but i am making the UserControl so i want to set it dynamically how could i get the desired output?
I tried using the code in .cs as below in the Constructor:
Style st = new Style(typeof(Xceed.Wpf.DataGrid.DataCell));
st.Setters.Add(new Setter(HorizontalAlignmentProperty, "Right"));
gd.Resources.Add("StyleForDataCell", st);
The above code is not working.
Kindly answer the post.
Thank You,
Paras Sanghani
Nothing Is Impossible