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
220
how to access Field's index in LabelPresenter's style?
posted

hi guys ,

I am trying to implement different column styles in a XamDataGrid . For example : column 0 is in styleA column 1 is in style2 and the columns are auto-generated .I want to set different Template for LabelPresenter with trigger in style .  see the xaml below :

        <Style x:Key="MYSTL" TargetType="{x:Type igDP:LabelPresenter}" >
            <Setter Property="Template">

                <Setter.Value>

                    <ControlTemplate TargetType="{x:Type igDP:LabelPresenter}">

                        <Grid>

                            <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
                            <Button Width="15" Height="15" x:Name="btnCol" HorizontalAlignment="Left" Content="X" >

                            </Button>

                        </Grid>

                    </ControlTemplate>

                </Setter.Value>

            </Setter>
            <Style.Triggers>
                <Trigger Property="here i want to get the index of the field" Value="0">

                    <Setter Property="Template">
                <Setter.Value>

                    <ControlTemplate TargetType="{x:Type igDP:LabelPresenter}">

                        <Grid>

                            <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </Grid>

                    </ControlTemplate>

                </Setter.Value>

            </Setter>
                </Trigger>
            </Style.Triggers>
        </Style>

Thanks

Ethan

Parents
No Data
Reply
  • 69686
    Verified Answer
    posted

    Hello Ethan,

    The Trigger will not allow you to create such a binding. You have to use a DataTrigger for this purpose and set its binding property. Set the RelativeSource to Self and the Path to Field.Index.

    Another way would be to createa a style and set it explicitly to that field from the Field's Settings ->LabelPresenterStyle.

Children
No Data