I have some data want to show as the picture. I want to try to use the xamldatagrid. I fill all of the data
in the ObservableCollection<T>. I want to set the Ideal # background as red when it is greater than the Total Exper. Please give me some code examples about this. Another question is how I can do the update to the database after editing the ideal #. Any help will be greately appreciated.
Thanks,
Hi,
One of the possible solution is to use IDataErrorInfo in order to color your data in specific way if doesn’t apply on some criteria’s. Which will be in your scenario Ideal # is less then Total Exper. And they should be implemented in your object class:
You can read more about the IDataErrorInfo here:http://help.infragistics.com/NetAdvantage/WPF/2010.1/CLR3.5/?page=WPF_IDataErrorInfo_Support.html
You can read more about how to enable IDataErrorInfo form here:http://help.infragistics.com/NetAdvantage/WPF/2010.1/CLR3.5/?page=xamDataPresenter_Enable_IDataErrorInfo_Interface_Support.html
You need to set the DataErrorDisplayMode to Highlight.
http://help.infragistics.com/NetAdvantage/WPF/2010.1/CLR3.5/?page=Infragistics3.Wpf.DataPresenter.v10.1~Infragistics.Windows.DataPresenter.DataErrorDisplayMode.htmlAbout the update, the error filed, this part is working as expected.I have attached a sample demonstrating this approach. Please let me know if you have any further questions.
Sincerely,DimiDeveloper Support Engineer, MCPD Infragistics, Inc.www.infragistics.com/support
Dimi,
Thanks for your greate support. Your solution works for me. But I want to know how I can approach this by setting editor styles in the xaml files like
<ig:Field Name="IdealNumber" Label="Ideal #" Row="1" Column="3" ColumnSpan="1">
<ig:Field.Settings>
<ig:FieldSettings AllowEdit="True" LabelTextAlignment="Center" EditAsType="{x:Type sys:Double}">
<ig:FieldSettings.EditorStyle>
<Style TargetType="{x:Type editors:XamNumericEditor}" >
<Setter Property="Mask" Value="{}{double:1.1}" />
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="Background" Value=??, Converter={StaticResource ValueToBrushConverter}}"/>
</Style>
</ig:FieldSettings.EditorStyle>
</ig:FieldSettings>
</ig:Field.Settings>
</ig:Field>
I use a flag field in my Object to indicate this. But I don't know how to set the value in the background setter. Please help on this. Thanks
thank for your patient support
If you would like to update in two ways the two fields and change the color only the one (ideal#) you should use MultiBinding. If you don’t want to update them you can use single binding like this:
<Setter Property="Background" Value="{Binding Path=Record, RelativeSource={RelativeSource Self}, Converter={StaticResource ValueToBrushConverter}}"/>
In order to get updated the filed color based on the two values changes you need to use MultiBinding:
<Style TargetType="{x:Type igDP:CellValuePresenter}" x:Key="IdealAgeFieldStyle"> <Setter Property="Background"> <Setter.Value> <MultiBinding > <MultiBinding.Converter> <converters:MultiConverter /> </MultiBinding.Converter> <MultiBinding.Bindings> <Binding Path="DataItem.Age" /> <Binding Path="DataItem.WorkingExpirience" /> </MultiBinding.Bindings> </MultiBinding> </Setter.Value> </Setter> <Setter Property="FontWeight" Value="Bold"/> <Setter Property="FontSize" Value="14"/> </Style>
Please see the attached sample for your reference.
Any reply?