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
65
XamGrid Styling - MouseOver cell and TemplateColumnLayout
posted

I'm trying to change the styling of the XamGrid to fit our application and can't find a few things.  First, when the mouse is over a cell I'd like to change the foreground color of the entire row to a specific color.  I've found where to do it for the cell, but I can't seem to find how to make it apply to the entire row when the mouse is over any cell in that row.

Also, I have a TemplateLayoutColumn that will be used to display additional details about the data record and allow the user to edit a few fields in that section.  I'd like to remove the highlighting that is done when you mouse over the expanded area.  Which style is that that needs to be overridden?

https://ibb.co/ggUhr5

This is a picture of the section I'm looking for.

Parents
No Data
Reply
  • 16495
    Offline posted

    Hello Christopher,

    You can change the foreground of entire row, when the mouse is over a cell from the same row,  by creating a style for CellsPanel. This way you can use a DataTrigger to check whether CellsPanel's IsMouseOver property is equal to true and  set the TextElement.Foreground to the color you wish:


    <Style TargetType="{x:Type igPrim:CellsPanel}">
        <Style.Triggers>
            <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self},Path=IsMouseOver}" Value="true">
                <Setter Property="TextElement.Foreground" Value="Red"/>
            </DataTrigger>
        </Style.Triggers>
    </Style>

    Regarding your second requirement for removing the highlight from expanded area you can handle the Loaded event of ColumnLayoutTemplateRowCellsPanel by using EventSetter in a Style for this element. Once you handle the event you can access the Rectangle that holds this highlight and set its Opacity to 0, for example:


    private void Panel_Loaded(object sender, RoutedEventArgs e)
    {
        var rec = Utilities.GetDescendantFromName((sender as ColumnLayoutTemplateRowCellsPanel) as DependencyObject, "AltMouseOver") as Rectangle;
        if (null != rec)
            rec.Opacity = 0;           
    }

    I have attached a simple sample application, where you can test this approach.

    Let me know if you have any questions.

    Sincerely,
    Zhivko
    Associate Software Developer

    XamGrid_Styling.zip
Children
No Data