Hi community
In a touch application we have Xamdatagrid that visualizes data. The application relies on the Infragistic themes and the user can switch between the themes during the runtime.
In one view we user the xamdatagrid to visualize data that is then sent to a service. The user clicks on the first column of the data row he wants to sent. The data is sent to a service and the background color of the row is set to green. This visualizes that the current data is active. But as the mouse/touch pointer is still over the marked row, the green is not always shown. So i set the color of the hover background and the hover border to transparent.
<igDP:XamDataGrid.Resources> <Style TargetType="{x:Type igDP:DataRecordCellArea}" BasedOn="{StaticResource {x:Type igDP:DataRecordCellArea}}" > <Setter Property="BackgroundHover" Value="Transparent" /> <Setter Property="BorderHoverBrush" Value="Transparent" /> </Style></igDP:XamDataGrid.Resources>
Now I want to set the text color of the foregroundHoverStyle, but I do not want to set it to a fixed value. It should reference the default foreground/inactive color of the datagrid cells from the current theme.
<Setter Property="ForegroundHoverStyle"> <Setter.Value> <Style> <Setter Property="TextBlock.Foreground" Value="{reference to the default foreground Color}"/> </Style> </Setter.Value></Setter>
How can I achieve this?
Thanks
Hello grubarec,
I am glad that you were able to find an alternative solution to this issue that you were having. I will continue to monitor this forum thread while I await your next response on this matter.
Please let me know if you have any other questions or concerns on this matter.
Sincerely,AndrewAssociate Developer
Hello Andrew!
Thank you for the sample, I will review it as soon as possible.
In the meantime, I have found a different solution for my problem. I am now using a datatrigger that sets the HoverBackground to green when the current row is active, and to shade of blue when the current data item is not active.
Hello Grubarec,
It sounds like the functionality that you are looking to achieve is that you are looking to bind the ForegroundHoverStyle's brush to the underlying Foreground brush from the current theme for the DataRecordCellArea. Please correct me if I am incorrect on this matter, as the following goes off of that impression.
In WPF, you can have only a single local theme, and there isn't really a way currently to say "Based On Current Theme" using the BasedOn tag of a Style. To do this, you would likely need to use a DynamicResource or something of the like, but unfortunately, BasedOn does not support this for the moment. With the current BasedOn tag that you have provided, you will be able to base on the default style of the DataRecordCellArea, but not the ones for other themes.
If you are indeed looking to bind the Foreground brush to the TextBlock.Foreground property in the ForegroundHoverStyle, you can do this by binding the Value to the following:
Value = "{Binding RelativeSource={RelativeSource Self}, Path=Foreground}"
However this will only work for the theme that is currently based on, and it may not work for all themes in the grid, as I believe in some themes, this foreground hover style is set in the CellValuePresenter style for the theme.
Note, it is possible to base off of specific themes in the XamDataGrid by using the following BasedOn statement:
//Where igThemes points at http://infragistics.com/ThemesBasedOn = "{x:Static igThemes:DataPresenterThemeName.DataRecordCellArea}"
Again, though, the issue here is that you cannot base off of something along the lines of "current theme." This leaves you with a few different options. For one, you could cover your bases and write an essentially duplicate DataRecordCellArea style and change the BasedOn for each of the XamDataGrid themes that you are looking to allow. Then, in the code that you are using to actually change the theme, you could get the corresponding style and apply it to the XamDataGrid.FieldLayoutSettings.DataRecordCellAreaStyle property programmatically.
Other options on this matter would include either dynamically generating a style for the above-mentioned property upon theme change, or you could include the theme files for the themes you are looking to implement and make your changes there. Then, instead of changing the theme directly for the XamDataGrid, you would merge the corresponding resource dictionary. These default theme files can commonly be found at the following directory:
C:\Program Files (x86)\Infragistics\2016.2\WPF\DefaultStyles\DataPresenter
I have attached a sample projects that demonstrates the "all bases covered" procedure mentioned above. I hope this helps you.