0

I have an Xceed datagrid where each cell template has a transparent background. Recently I placed a ReadOnly TextBox inside one of the cell templates. This allows the user to click into the cell and select a subset of the text. However, one side effect is that the cell turns white when I click on the TextBox.

Here's the column:

                <xcdg:Column Title="{x:Static rcer:CEWR.Field_PinyinDefinition}"
                             AllowGroup="False"                                
                             ReadOnly="True"                                 
                             CellContentTemplate="{StaticResource ceItemsCellContentTemplate}"
                             FieldName="Items">
                    <xcdg:Column.TitleTemplate>
                        <DataTemplate>
                            <TextBlock Foreground="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" Text="{Binding}" />
                        </DataTemplate>
                    </xcdg:Column.TitleTemplate>
                </xcdg:Column>

and the template

<DataTemplate x:Key="ceItemsCellContentTemplate">
    <DataTemplate.Resources />
    <ItemsControl Margin="0"
                  Background="Transparent"
                  ItemTemplate="{StaticResource ceItemTemplate}"
                  ItemsSource="{Binding}"
                  Padding="0"
                  Style="{StaticResource itemsBoxStyle}">
        <ItemsControl.ItemContainerStyle>
            <Style TargetType="ContentPresenter">
                <Style.Triggers>
                    <Trigger Property="IsFocused" Value="True">
                    </Trigger>
                </Style.Triggers>
            </Style>
        </ItemsControl.ItemContainerStyle>
        <ItemsControl.LayoutTransform>
            <ScaleTransform ScaleX="{Binding Zoom, Source={StaticResource ceShowSettings}}" ScaleY="{Binding Zoom, Source={StaticResource ceShowSettings}}" />
        </ItemsControl.LayoutTransform>
    </ItemsControl>
</DataTemplate>

Here it is turning the cell background white

enter image description here

I tried messing with the ItemsControl, but that is not it. It must be something like the CellContentStyle - which is not accessible so far.

Update. I can set CanBeCurrentWhenReadOnly="False" and the background will stay when i click on the TextBox definition, but I won't be able to interact with the contents of the cell.

tofutim
  • 22,664
  • 20
  • 87
  • 148

1 Answers1

0

Here's how to do it.

<Style TargetType="{x:Type xcdg:DataCell}">
    <Setter Property="CurrentBackground" Value="Transparent"/>
</Style>
tofutim
  • 22,664
  • 20
  • 87
  • 148