We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How do change BorderStyle of a row with StyleSelector

Hello,
I've got a Datagrid. At the moment I'm changing the background of a row if a certain value is changing. I do it this way:

xmlns:sfgrid="clr-namespace:Syncfusion.UI.Xaml.Grid;assembly=Syncfusion.SfGrid.WPF"


<Style x:Key="gridRowBet" TargetType="sfgrid:VirtualizingCellsControl">

            <Style.Triggers>

                <DataTrigger Binding="{Binding HasBet}" Value="True">

                    <Setter Property="Background" Value="Red"/>

                </DataTrigger>

            </Style.Triggers>

</Style>


I
I'm not satified with the solution and want following behaviour instead: I've the DataTrigger changes I want to Border of the row become thicker and change color.
How can I do this.

Thanks

Markus
       

3 Replies

AN Ashok N Syncfusion Team September 7, 2015 12:23 PM UTC

Hi Markus,

Thank you for contacting Syncfusion support.

We have analyzed your query and we have prepared the sample to change the Background of the row based on the CellValue by using RowStyleSelector. You 

can download the sample from the below sample location

Sample location: http://www.syncfusion.com/downloads/support/forum/120151/ze/SimpleApplication_(2)-1508463314 

Please refer the below UG link to get more details regarding styles-and-templates in SfDataGrid

http://docs.syncfusion.com/wpf/sfdatagrid/styles-and-templates 

Please let us know if you require further assistance on this.

Thanks,

Ashok



SX SXTrader replied to Ashok N September 16, 2015 08:04 PM UTC

Hi Markus,

Thank you for contacting Syncfusion support.

We have analyzed your query and we have prepared the sample to change the Background of the row based on the CellValue by using RowStyleSelector. You 

can download the sample from the below sample location

Sample location: http://www.syncfusion.com/downloads/support/forum/120151/ze/SimpleApplication_(2)-1508463314 

Please refer the below UG link to get more details regarding styles-and-templates in SfDataGrid

http://docs.syncfusion.com/wpf/sfdatagrid/styles-and-templates 

Please let us know if you require further assistance on this.

Thanks,

Ashok


Hello,
thanks for your reply.
As I said I'm using XAML-Style Triggers. Now I've encountered a problem I couldn't explain yet. I'm trying to change the Forecolor of the Text in a Grid Row with Data Triggers. For some reasons it does not work.

I've tried the Row Style and the Cell Style for manipulation.

I've attached an example project to this post.

Could you please give me a hint what I'm doing wrong as I haven't found the solutions in the documentation yet.

Attachment: SXTippster_example_background_1c38151a.zip


GL Ganeshkumar Lingappan Syncfusion Team September 17, 2015 08:27 AM UTC

Hi ­­Markus,
Sorry about the inconvenience caused
We have analyzed your query. SkinManager applies styles for all Microsoft controls and Syncfusion Tools and shared controls. GridCell is a ContentControl which loads TextBlock as its Content. Even though if you set Foreground to GridCell, Still the TextBlock will load with the style applied via SkinManager. We can overcome this problem by writing style for TextBlock as in the following code example and refer to the modified sample in the mentioned location
Code-Example

<Window. Resources>

        <Style x:Key="gridRowBet" TargetType="sfgrid:VirtualizingCellsControl">

            <Style.Triggers>

                <DataTrigger Binding="{Binding HasBet}" Value="True">

                    <Setter Property="Background" Value="Green"/>                   

                </DataTrigger>

            </Style.Triggers>

            <Style.Resources>

                <Style TargetType="{x:Type TextBlock}">

                    <Setter Property="Foreground" Value="White" />

                </Style>

            </Style.Resources>

        </Style>


        <Style x:Key="gridCellBet" TargetType="syncfusion:GridCell">

            <Style.Triggers>

                <DataTrigger Binding="{Binding HasBet}" Value="True">

                    <Setter Property="Background" Value="Green"/>                   

                    <Setter Property="FontWeight" Value="ExtraBold" />

                </DataTrigger>

            </Style.Triggers>

            <Style.Resources>

                <Style TargetType="{x:Type TextBlock}">

                    <Setter Property="Foreground" Value="White" />

                </Style>

            </Style.Resources>

        </Style>
</Window.Resources>


Sample-Link: http://www.syncfusion.com/downloads/support/forum/120151/ze/SXTippster_example_background767644525
Regards,
Ganeshkumar



Loader.
Up arrow icon