How do I set the background on a XamDataCard?
Hello Janimi,
In order to change the background color of one field you could use a style for the CellPresenter and set its Key property to some value. Then you could change the background color and use the style as StaticResource for the CellPresenterStyle property of the Field. You could also set the AllowEdit property to true to the fields you want to be editable and to false to the ones that should not be editable:
<Window.Resources>
<Style x:Key="CellStyle" TargetType="{x:Type igDP:CellPresenter}">
<Setter Property="Background" Value="Yellow"/>
</Style>
</Window.Resources>
…
<igDP:Field Name=" Real Weight" >
<igDP:Field.Settings>
<igDP:FieldSettings CellPresenterStyle="{StaticResource CellStyle}" AllowEdit="True"/>
</igDP:Field.Settings>
</igDP:Field>
Please feel free to let me know if you have any other questions.
Hello Maria,
with your style sample I was able to make the background of all fields yellow. What about when I just want to set the backgroundcolor of a single field of a datacard, how can I do that? And I want to make all the other fields not editable. So my field "Real Weight" should have a yellow background and should be editable, the other fields should not. Right now my datacard Looks like this:
<igDP:XamDataCards Grid.Row="2" HorizontalAlignment="Left" Margin="12,12,0,0" Name="xamDataCards1" VerticalAlignment="Top" DataSource="{Binding ElementName=xamMultiColumnComboEditor1, Path=SelectedItems}"> <igDP:XamDataCards.FieldLayouts> <igDP:FieldLayout > <igDP:FieldLayout.Fields> <igDP:Field Name="Name" Label="Name" /> <igDP:Field Name="Volume" Label="Volume" /> <igDP:Field Name="TargetWeight" Label="Target Weight" /> <igDP:Field Name="ImageUrl" Label="Image" /> <igDP:UnboundField Name ="RealWeight" Label="Real Weight"> </igDP:UnboundField> </igDP:FieldLayout.Fields> </igDP:FieldLayout> </igDP:XamDataCards.FieldLayouts> </igDP:XamDataCards>
Hello Rachita,
Thank you for your feedback. I am glad that you resolved your issue.
If you have any other questions, please do not hesitate to ask.
It worked thanks :)
When you use a theme, the style for the theme is applied over all other styles and this is the reason why the alignment of the text is not changed if you use a style. In order to apply your custom style you could use its BasedOn property in order to show the values left aligned. Here is a code snippet where I use LunaOlive theme:
<Style TargetType="{x:Type editors:XamNumericEditor}" BasedOn="{x:Static igThemes:EditorsLunaNormal.XamNumericEditor}">
<Setter Property="HorizontalContentAlignment" Value="Left"/>
I attached a sample project demonstrating this. If you have any other questions, please do not hesitate to ask.