Hi,
I have a XamDataGrid with 5 Columnswich are representing boolean values. Now i want to change the CellLayout for all five columns, so that there is a green or red circle depending on the boolean value.
So i wrote a CellValuePresenterStyle as follows:
<Style x:Key="BoolCellStyle" TargetType="{x:Type igDP:CellValuePresenter}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}"> //<--CircleDefinition Name="circle" Fill="Red"-->//
<ControlTemplate.Triggers> <DataTrigger Binding="{Binding Path=DataItem.Bool1}" Value="true"> <Setter TargetName="circle" Property="Fill" Value="Green" /> </DataTrigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style>
Adding this style to the Field works fine. But only for column "Bool1" and want to have 5 BooleanColumns looking all identically.But in the DataTrigger of "BoolCellStyle" is an explicit reference to Column "Bool1". Of course, i am able to define 5 different(not really :)) BoolCellStyle's which only difference is the dataTrigger Binding (DataItem.Bool1, DataItem.Bool2, DataItem.Bool3.....). But i dont think that infragistics intend such an approach. So, how it is possible to write ONE cellStyle referencing on the cellValue, without an explicit Binding to a ColumnName.?
Changing the DataTrigger Binding to
<DataTrigger Binding="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Value}" Value="true">
wont work. :(
I am very pleased for any suggestions to solve this on an elegant way.
axel
no idea to this topic? :(
Hi axel,
I've found a solution. Try this..
public class BLLObject{ public bool Col1 { get; set; } public bool Col2 { get; set; } public bool Col3 { get; set; } public bool Col4 { get; set; } public bool Col5 { get; set; }
public BLLObject(bool col1Value, bool col2Value, bool col3Value, bool col4Value, bool col5Value) { Col1 = col1Value; Col2 = col2Value; Col3 = col3Value; Col4 = col4Value; Col5 = col5Value; }}
xamDataGrid1.DataSource = bllSource; }}
<Window x:Class="XamDataGridEditor.Window1" xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml Title="Window1" Height="300" Width="300" xmlns:igDP="http://infragistics.com/DataPresenter"> <Grid> <igDP:XamDataGrid Name="xamDataGrid1"> <igDP:XamDataGrid.Resources> <Style TargetType="{x:Type igDP:CellValuePresenter}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}"> <Ellipse Name="circle" Width="16" Height="16" Fill="Red" /> <ControlTemplate.Triggers> <DataTrigger Binding="{Binding Value, RelativeSource={RelativeSource Self}}" Value="True"> <Setter TargetName="circle" Property="Fill" Value="Green" /> </DataTrigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style> </igDP:XamDataGrid.Resources> </igDP:XamDataGrid> </Grid></Window>
Best regards,atus
Hi atus,
many thanks for your solution. Work perfectly!
Axel
What if I want to bind to something besides value, for example, a IsValidXXX (where x is the column name) method on the Record.DataItem?