Hi,
I've created a custom Unbound field and a style for it as well.
<igDP:UnboundField x:Class="My.Grids.Controls.FieldTypes.TradingStatusField" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:igDP="http://infragistics.com/DataPresenter" xmlns:igEditors="http://infragistics.com/Editors"> <igDP:Field.Settings> <igDP:FieldSettings LabelTextAlignment="Left" EditAsType="{x:Type sys:String}" DataValueChangedNotificationsActive="True" AutoSizeOptions="All" AutoSizeScope="AllRecords"> <igDP:FieldSettings.EditorStyle> <Style TargetType="{x:Type igEditors:XamTextEditor}"> <Setter Property="HorizontalContentAlignment" Value="Left"/> </Style> </igDP:FieldSettings.EditorStyle> </igDP:FieldSettings> </igDP:Field.Settings></igDP:UnboundField>
<Style x:Key="TradingStatusStyle" TargetType="{x:Type igDP:CellValuePresenter}" BasedOn="{StaticResource {x:Type igDP:CellValuePresenter}}"> <Setter Property="Foreground" Value="Orange"/> <Style.Triggers> <DataTrigger Binding="{Binding ?" Value="Trading"> <Setter Property="Foreground" Value="#00A300"/> </DataTrigger> <DataTrigger Binding="{Binding ?}" Value="Closed"> <Setter Property="Foreground" Value="Red"/> </DataTrigger> </Style.Triggers> </Style>
How can I have the trigger bind to the BindingField property of the cell?
I won't know if the user will call the property Status or TradingStatus or Foo for that matter beforehand and since this is an unboundField I don't know the level of nesting that will be bound to this field i.e.
<my:TradingStatusField BindingPath="SomeParent.ItsChild.AndGrandChild.Status"/>
How can I in the style get to the last property in the BindingPath and trigger on that value?
Cheers,
nisbus
Well, I found a way to do it:
<Style x:Key="TradingStatusStyle" TargetType="{x:Type igDP:CellValuePresenter}" BasedOn="{StaticResource {x:Type igDP:CellValuePresenter}}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}"> <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Value}"> <TextBlock.Style> <Style TargetType="{x:Type TextBlock}"> <Style.Triggers> <DataTrigger Binding="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Value}" Value="Trading"> <Setter Property="Foreground" Value="#00A300"/> </DataTrigger> <DataTrigger Binding="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Value}" Value="Closed"> <Setter Property="Foreground" Value="Red"/> </DataTrigger> </Style.Triggers> </Style> </TextBlock.Style> </TextBlock> </ControlTemplate> </Setter.Value> </Setter> <Setter Property="Foreground" Value="Orange"/> </Style>
I hope it helps someone