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
XamGrid: styles for controls in Editor template are not applies
posted

Hello 

Could please help me with that?

See my attached project.

Editor template styles issue.zip

  • 34510
    Verified Answer
    Offline posted

    Hi Vasily,

    That style isn't getting applied because the XamGrid is trying to apply the column's EditorStyle to the root element in the DataTemplate which happens to be the TextBox.  There are two options here:

    1.) You can move your style to the column's EditorStyle property

    <ig:TemplateColumn.EditorTemplate>
        <DataTemplate>
            <TextBox x:Name="TextBox"/>
        </DataTemplate>
    </ig:TemplateColumn.EditorTemplate>
    <ig:TemplateColumn.EditorStyle>
        <Style TargetType="TextBox">
            <Setter Property="Text" Value="Hello"/>
        </Style>
    </ig:TemplateColumn.EditorStyle>

    2.) You can place the TextBox into a Grid element so the XamGrid can't override your style

    <ig:TemplateColumn.EditorTemplate>
        <DataTemplate>
            <Grid>
                <TextBox x:Name="TextBox">
                    <TextBox.Style>
                        <Style TargetType="TextBox">
                            <Setter Property="Text" Value="Hello"/>
                        </Style>
                    </TextBox.Style>
                </TextBox>
            </Grid>
        </DataTemplate>
    </ig:TemplateColumn.EditorTemplate>