Hello,
when using a custom CellValuePresenter style, the font color doesn't change according to the highlighted or selected row font color, when selected. How can I use the same font color in my CellValuePresenter as for highlighted or selected default cells, when this cell is also highlighted?
See screenshot.
Here is the corresponding xaml code, for that cell:
<Style x:Key="styleMutltilineCell" TargetType="{x:Type igDp:CellValuePresenter}" BasedOn="{x:Static igTheme:DataPresenterMetroDark.CellValuePresenter}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type igDp:CellValuePresenter}"> <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"> <TextBlock Text="{TemplateBinding Value}" TextWrapping="Wrap" Padding="{TemplateBinding Padding}" VerticalAlignment="Center"/> </Border> </ControlTemplate> </Setter.Value> </Setter> </Style>
Hello Markus,
If I understood correctly what you need to achieve is wrapping the content of the cells in your XamDataGrid. In this case I suggest to create a style for the fields' editors and set their "TextWrapping" property to value "Wrap" instead of re-templating the CellValuePresenters. Also you can set the FieldLayoutSettings's DataRecordSizingMode property to SizedToContentAndIndividuallySizable mode. I have implemented this approach in the sample application I am attaching for your reference.
If you need any further assistance, please, do not hesitate to let us know.
Sincerely,ZhivkoAssociate Software Developer
Thanks.
Using the ContentTemplate doesn't work in my case, because when wrapping the TextBlock, the grid row is not resizing. It still remains the same height.
Copying an existing style and modifying it would destroy the possibility to change the whole theme easily.
It would be good if the TextField property of the FieldSettings whould have an option "TextWrapping", so I can use easily multiline cells, without copy and altering a specific theme style.
By changing the whole Template of the CellValuePresneter you may lose some of the default behavior of the cells so I believe that in your case if the goal is to set some TextBlock properties may be more suitable if you change the CellValuePresneter’s ContentTemplate instead of ControlTemplate. Therefore in your style you can set the ContentTemplate property by providing different DataTemplates for it depending on your requirements.
Also an available approach is to copy the style for CellValuePresenter from the default styles and modify it as you wish. It is located on the following location on your machine:
C:\Program Files (x86)\Infragistics\\WPF\DefaultStyles\DataPresenter\DataPresenterMetroDark_Express.xaml
Let me know if you have any questions.