Home Forums WPF controls Xceed DataGrid for WPF Applying Row level formatting

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #22001 |

    Hi Folks,
    I confess, this has me stumped. I am trying to apply a format across an entire row based on the status of a flag. Think of this as a list of emails and some of them are read and some are unread

    so my grid looks like. (some things left out to keep the code concise)
    <Grid xmlns:xcdg=”http://schemas.xceed.com/wpf/xaml/datagrid”&gt;
    <xcdg:DataGridControl>
    <xcdg:DataGridControl.Columns>
    <xcdg:Column FieldName=”Subject”/>
    <xcdg:Column FieldName=”DateSent”/>
    <xcdg:Column FieldName=”Sender”/>
    <xcdg:Column FieldName=”Viewed” />
    </xcdg:Column>
    </xcdg:DataGridControl.Columns>
    </xcdg:DataGridControl>

    so far so good – but then i am at a lost as to where to head…
    there is an example of how to add a style (from the docs)
    <Grid.Resources>
    <Style TargetType=”{x:Type xcdg:DataCell}”>
    <Setter Property=”CurrentForeground”>
    <Setter.Value>
    <SolidColorBrush Color=”Yellow”/>
    </Setter.Value>
    </Setter>
    </Style>
    </Grid.Resources>

    but this does not change anything in my grid… what am I missing??

    thanks,
    Lucas

    Imported from legacy forums. Posted by Lucas (had 3708 views)

    User (Old forums)
    Member
    Post count: 23064

    You could try the following:

    <Grid.Resources>
    <Style TargetType=”{x:Type xcdg:DataRow}”>
    <Style.Triggers>
    <DataTrigger Binding=”{Binding Path=[Flag]}” Value=”Read”>
    <Setter Property=”Background”>
    <Setter.Value>
    <SolidColorBrush Color=”Blue” />
    </Setter.Value>
    </Setter>
    </DataTrigger>
    </Style.Triggers>
    </Style>
    </Grid.Resources>

    Imported from legacy forums. Posted by M (had 370 views)

    Xceed Support
    Member
    Post count: 5658

    Hi Lucas,

    I tried reproducing the same thing, using all views/themes, and the foreground when a cell becomes current effectively turns yellow for me…

    I’d like to have a little bit more of context, just to make sure I didn’t miss anything…

    – You said you removed some code for readability: Are you using custom CellContentTemplates or CellEditors on your columns?

    As for your specific context (read/unread emails), I think you could easily achieve this kind of visual customization using something like this:

    (see code example in next post)

    Imported from legacy forums. Posted by Marcus [Xceed] (had 291 views)

    Xceed Support
    Member
    Post count: 5658

    <code>
    <Grid.Resources>

    <Style TargetType=”{x:Type xcdg:DataRow}”>
    <Style.Triggers>
    <!– Bind the trigger to the property indicating if the mail is read or unread –>
    <DataTrigger Binding=”{Binding IsRead}” Value=”False”>
    <Setter Property=”Foreground” Value=”Red”/>
    <Setter Property=”TextElement.FontWeight” Value=”Bold”/>
    </DataTrigger>
    </Style.Triggers>
    </Style>

    </Grid.Resources>
    </code>

    Imported from legacy forums. Posted by Marcus [Xceed] (had 316 views)

    Xceed Support
    Member
    Post count: 5658

    Hehehe, me and Marcel had the same idea. He was just faster than me!!! 😉

    Imported from legacy forums. Posted by Marcus [Xceed] (had 5142 views)

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.