Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
55
Define multiple column styles in app.xaml
posted

I am trying to define column styles for grids across my application. There would be many different Text format's and numeric formats that I will have to define and I want the styles of columns of similar type to remain consistent. For instance the simplest example of this would be like as shown below. One defines a double format and one an int format. How can I define these styles within app.xaml then specify EditAsType to XamNumericEditor and then use one of these styles based on name or some other attribute?

 <Style x:Name="DoubleStyle" TargetType="{x:Type igEditors:XamNumericEditor}">

 

 

 

 

 

<!--Right justify the value in the column for Numeric Editor-->

 

 

 

 

 

<Setter Property="HorizontalAlignment" Value="Right" />

 

 

 

 

 

<Setter Property="HorizontalContentAlignment" Value="Right" />

 

 

 

 

 

<Setter Property="Format" Value="#,##0.0#"/>

 

 

 

 

 

</Style>

 

<Style x:Name="IntStyle" TargetType="{x:Type igEditors:XamNumericEditor}">

 

 

 

 

 

 

<!--Right justify the value in the column for Numeric Editor-->

 

 

 

 

 

<Setter Property="HorizontalAlignment" Value="Right" />

 

 

 

 

 

 

<Setter Property="HorizontalContentAlignment" Value="Right" />

 

 

 

 

 

 

<Setter Property="Format" Value="#,##0"/>

 

 

 

 

 

 

</Style>

  • 138253
    Verified Answer
    Offline posted

    Hello,

     

    Thank you for your post. I have been looking through it and I created a sample project for you with the functionality you need. Basically I copied your styles in the App.xaml file, but instead of setting their Names’ Properties I set their Keys, by which you can set them through the StaticResources of your application. All of this is shown in the sample I attached.Please let me know if you need further clarifications on this matter.

     

    Looking forward for your reply.

    XamDataGridStyles.zip