2016-03-11 33 views
0

我有一個Xceed數據網格,其中每個單元格模板都有一個透明背景。最近我在其中一個單元格模板中放置了一個ReadOnly TextBox。這允許用戶點擊單元格並選擇文本的一個子集。但是,其中一個副作用是單擊TextBox時單元格會變成白色。防止細胞背景在焦點上變爲白色

這裏的列:

   <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> 

<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> 

這是打開單元格背景白色

enter image description here

我試着用的ItemsControl搞亂的模板,但那不是。它必須是像CellContentStyle - 目前無法訪問的。

更新。我可以設置CanBeCurrentWhenReadOnly =「False」 ,當我點擊TextBox定義時,背景將保持不變,但我將無法與單元格的內容進行交互。

回答

0

下面介紹如何操作。

<Style TargetType="{x:Type xcdg:DataCell}"> 
    <Setter Property="CurrentBackground" Value="Transparent"/> 
</Style>