Hello,
I am looking to achieve something like this
<igDP:XamDataGrid.FieldLayoutSettings>
basically, for each row we have our setting to display like BG/FG colors, Font style etc. so instead of writing three/four converters which get applied for one row I was thinking if we could achieve something like above where we assign styles based on data in the row.
Please help.
It seems to compile and everything, it just doesn't the break point in the converter.
public object Convert(object value, Type targetType,object parameter, CultureInfo culture){
if (value == null) return Binding.DoNothing;
TransactionViewModel model = value as TransactionViewModel;
if (model==null)return Binding.DoNothing;
Style style = new Style();
style.Setters.Add(
new Setter(DataRecordCellArea.BackgroundProperty, Brushes
.Red ));
return style;
}
I am just checking the progress of this issue and was wondering if you managed to achieve your goal or if you need any further assistance on the matter.
Hello Vish,
When you look at my sample, please let me know if it helps you or you need further assistance on this matter.
Looking forward for your reply.
Hello,,
Just looked at the solution that you provider, unfortunately this is not what I was looking for.
I need to set all (Background, foreground, font, font weight, font style) so from the converter I need to return a Style obect for the row instead of just a background color.
How can I set the style of the DataRecordPresenter using Converter. One way would be to write 3-4 converters one for each property that I need to set. But that's doesn't sound good.
RegardsVish
I modified the sample project I sent you before, so now you can set all the Properties you want based on the Record’s data. Basically I add DataTriggers bound to the Record and with a converter I returned the Records’ LastName, but you can make whatever checks you want in your converter and return different values for the different DataTriggers you create. Please let me know if need further clarifications on this matter.
Hello Stefan,
Thanks for your response. I think I am unable to explain my problem properly. Let me try now.
What happens is in our app we allow user to create their own style for rows (so we can not hardcode these in xaml) lets say a user has set following styles (another user can have different style for same rules)1. State=Canceled => will have Background Red and Foreground White and Bold2. State=New and Date < today =>BG=Blue and FG=Black3. State=Newe and Date=Today =>BG = White and FG=BlackI understand that one way would be to set these in Style <Style TargetType="{x:Type igDP:DataRecordPresenter}"> <Setter Property="Background" Value="{Converter BGcolorSelector}"/> <Setter Property="Foreground" Value="{Converter FGcolorSelector}"/></Style>
I was looking something different so that I could bind the Style object itself, exposed as property by the Record in the collectionsomething like
<XamDatGrid DataSource="{Binding}"><igDP:XamDataGrid.FieldLayoutSettings ><igDP:FieldLayoutSettings DataRecordPresenterStyleSelector="{my:RecordStyleConverter}" /></igDP:XamDataGrid.FieldLayoutSettings>
</XamDataGrid>I need to know what do I need to write for my:RecordStyleConverter so that whole of the style gets assigned via converter or via a property exposed by the object.
I hope this makes my problem more clear.
I am just checking if you got this worked out or you still require any assistance or clarification on the matter.
I suggest you add UnboundFields once you have you Fieldlayout initialized and bound them to the Properties of your underlying data. Here it is explained in details about the UnboundFields:
http://help.infragistics.com/NetAdvantage/WPF/2011.2/CLR4.0/?page=InfragisticsWPF4.DataPresenter.v11.2~Infragistics.Windows.DataPresenter.UnboundField.html
Hope this helps you.