简体   繁体   中英

Change FontWeight of specific row of DevExpress GridControl in WPF

I want to Change the FontWeight of a specific row to bold. So i have a DataTable (MyDataTable):

Name     Location
-------------------
Mark     New-York
Julian   Paris
Donald   Moscow

which i bind to a DevExpress GridControl

<dxg:GridControl ItemsSource="{Binding MyDataTable}">

Now i would like to Change the FontWeight of the row where the Name is 'Julian'. How can i do this?

I thought using a DataTrigger like:

 <dxg:GridControl.Resources>
                <Style TargetType="{x:Type dxg:GridRow}">
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding MyDataTable.Columns[0]}" Value="Name">
                            <Setter Property="FontWeight" Value="Bold"/>
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </dxg:GridControl.Resources>

but this is not working. I tried several other Options, but did not find a working solution. Can someone please guide me in the right direction? I would very much prefer to do it directly in xaml and not in code behind, if this is possible.

Use FormatConditions Property to format row or cell with condition

<dxg:TableView.FormatConditions> <dxg:FormatCondition Expression="[Name] = 'Julian'" FieldName="Name" />

EDIT:

If you want formatting in code - Formatting in Code

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM