We are using a xamDataGrid (v12.2) and would like both the row and column to be highlighted when the user hovers over a cell in the grid. The row highlighting is already built-in but I’ve been unable to figure out how to do this for the column. Either highlighting the entire column or just the header would be sufficient.
Thanks
HI,
I am attaching a sample that highlights the cells in a column when a hover occurs.
Sincerely,
Matt
Developer Support Engineer
Hi Matt,
Thank you for your sample solution. This is exactly what I am trying to do. I was hoping there would be a simpler approach although I was wondering if it was going to be something like this.
I am having issues getting it to work in my solution though. I cannot create an instance of “VM” in my XAML. I believe this is because I need to pass a parameter to my ViewModel before I bind to it. If I didn’t want to reference my ViewModel in my XAML how could I adjust this solution to accommodate that. I am currently unable to pass the actual Field Name through to the Converter.
Also, we are going to end up with 200-300 columns (with about 40 ever being visible at a time) . Is there going to be performance issues trying to highlight a column on hover doing it this way?
Well performance could be an issue, you should try it out, its not much code to implement.
As far as your vm issues, add another binding to the multibinding, element name = layoutroot, path-=datacontext (this should bring in your viewmodel)
You could also just do the header hight.
Here a code snippet to just do the header
<Style TargetType="{x:Type igDP:LabelPresenter}"> <Setter Property="Background"> <Setter.Value> <MultiBinding Converter="{StaticResource bmulticonv}"> <Binding Source="{StaticResource vm}" Path="FieldName"/> <Binding RelativeSource="{RelativeSource self}" Path="Field"/> </MultiBinding> </Setter.Value> </Setter> </Style>
<Style TargetType="{x:Type igDP:CellValuePresenter}"> <EventSetter Event="MouseLeave" Handler="CellValuePresenter_MouseLeave"/> <EventSetter Event="MouseEnter" Handler="CellValuePresenter_MouseEnter"/> <EventSetter Event="PreviewMouseMove" Handler="CellValuePresenter_PreviewMouseMove"/> <!--<Setter Property="Background"> <Setter.Value> <MultiBinding Converter="{StaticResource bmulticonv}"> <Binding Source="{StaticResource vm}" Path="FieldName"/> <Binding RelativeSource="{RelativeSource self}" Path="Field"/> </MultiBinding> </Setter.Value> </Setter>--> </Style>
Sincerely, Matt
Please let me know if you need further assistance regarding this issue.
Matt Developer Support Engineer