Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
270
Problem wirth CellValuePresenter
posted

 Hi ,

 

I have a XamDataGrid with a  Boolean Field 

<igDP:Field Label="Status" Name="{Binding Source={StaticResource dm_Dispo_Status}, Path=Path}"></igDP:Field>

The Value is shown correctly in an CheckBox.

 Now i want to add a style to represent the value as an red or green rect.

             <Style x:Key="StatusCellStyle" TargetType="{x:Type igDP:CellValuePresenter}">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}">
                            <Rectangle Width="15" Name="rect" Height="15" Fill="Red"/>
                            <ControlTemplate.Triggers>
                                <DataTrigger Binding="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Value}" Value="true">
                                    <Setter TargetName="rect" Property="Fill" Value="Green" />
                                </DataTrigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>

and i add this style to the specific Field 

 <igDP:FieldSettings CellValuePresenterStyle="{StaticResource StatusCellStyle}"/>

 But it wont work. The rect is always red.

 

I found this exampleand wondering, because there is the style set on the same way. So where is the problem.

 http://help.infragistics.com/Help/NetAdvantage/WPF/2007.1/CLR3.X/HTML/Infragistics3.Windows.DataPresenter.v7.1~Infragistics.Windows.DataPresenter.FieldSettings~CellValuePresenterStyle.html

 Thanks.

Axel

 

 

 

 

 

  • 270
    posted

     Ok, the positive thing that there is a solution, the bad thing is that i couldnt use it directly. The problem is the Binding in the data trigger.

    Wrong version: <DataTrigger Binding="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Value}" Value="true">

    Correct version:<DataTrigger Binding="{Binding Path=DataItem.!!!APropertyName!!!}" Value="true">

     The problem now is, that i dont have the real property name. It is covered in a StaticResource because Property Names can changed during the development process.To handle this we created this resources which are mapping the propertyNames. So if the PropertyNames are Changing we dont have to change 1 billion controls, we only change the ressource.

    The XamDataGrid Field is now initialized as follows:

    <igDP:Field Label="Status" Name="{Binding Source={StaticResource dm_Status}, Path=Path}"></igDP:Field> 

     where dm_Status Maps the Property Name to the field. This works fine.

     

     The Problem  with the CellValuePresenteStyle is now that i couldnt writesomething like

    <DataTrigger Binding="{Binding Path=DataItem.!!!APropertyName!!!>}" Value="true"> 

     becaue !!!APropertyName!!! is covered behind a Ressource which is looking something like that

    <my:PropertyMapper Path="!!!APropertyName!!!" ObjectType={x:Type XXX} ..../>

     

    I hope you understand my problem.I thought with the Binding="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Value}" i get the value of the Cell, but it doesnt seems so.

     

    Thx

    Axel