zoukankan      html  css  js  c++  java
  • 选中DataGrid的Cell而不是row

    主要是针对DataGridCellsPresenter而不是SelectiveScrollingGrid,使用时DataGridRow应用这个style就可以了。
    

    <Style x:Key="grdStudyListDataGridRowStyle" TargetType="{x:Type DataGridRow}">
                    <Setter Property="SnapsToDevicePixels" Value="true"/>
                    <Setter Property="Validation.ErrorTemplate" Value="{x:Null}"/>
                    <Setter Property="ValidationErrorTemplate">
                        <Setter.Value>
                            <ControlTemplate>
                                <TextBlock Foreground="Red" Margin="2,0,0,0" Text="!" VerticalAlignment="Center"/>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="{x:Type DataGridRow}">
                                <Grid x:Name="DGR_Border" Background="{TemplateBinding Background}" SnapsToDevicePixels="True" Width="Auto">
                                    <SelectiveScrollingGrid x:Name="selectiveScrollingGrid" d:LayoutOverrides="Width">
                                        <SelectiveScrollingGrid.ColumnDefinitions>
                                            <ColumnDefinition Width="Auto"/>
                                            <ColumnDefinition Width="*"/>
                                        </SelectiveScrollingGrid.ColumnDefinitions>
                                        <SelectiveScrollingGrid.RowDefinitions>
                                            <RowDefinition Height="*"/>
                                            <RowDefinition Height="Auto"/>
                                        </SelectiveScrollingGrid.RowDefinitions>
                                        <Border x:Name="bdCell"  Grid.Column="1" HorizontalAlignment="Left">
                                            <DataGridCellsPresenter ItemsPanel="{TemplateBinding ItemsPanel}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalContentAlignment="Center" HorizontalContentAlignment="Center"/>
                                        </Border>
                                        <DataGridDetailsPresenter Grid.Column="1" Grid.Row="1" SelectiveScrollingGrid.SelectiveScrollingOrientation="{Binding AreRowDetailsFrozen, ConverterParameter={x:Static SelectiveScrollingOrientation.Vertical}, Converter={x:Static DataGrid.RowDetailsScrollingConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}" Visibility="{TemplateBinding DetailsVisibility}"/>
                                        <DataGridRowHeader Grid.RowSpan="2" SelectiveScrollingGrid.SelectiveScrollingOrientation="Vertical" Visibility="Collapsed"/>
                                    </SelectiveScrollingGrid>
                                </Grid>
                                <ControlTemplate.Triggers>
                                    <DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="True">
                                        <Setter Property="Background" TargetName="bdCell" Value="{DynamicResource Brush_PA_CSW_DataGridItemDefaultHighlight}"/>
                                    </DataTrigger>
                                    <MultiDataTrigger>
                                        <MultiDataTrigger.Conditions>
                                            <Condition Binding="{Binding (FrameworkElement.DataContext).CurrentDeletingLevel, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}" Value="Study"/>
    
                                            <Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="True" />
                                        </MultiDataTrigger.Conditions>
                                        <Setter Property="Background" TargetName="bdCell" Value="{DynamicResource Brush_PA_CSW_DataGridItemHighlight}"/>
                                    </MultiDataTrigger>
                                </ControlTemplate.Triggers>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                    <Setter Property="Background" Value="Transparent"/>
                </Style>
    
  • 相关阅读:
    JBOSS管理数据库连接
    PowerDesigner使用教程 —— 概念数据模型
    VC Delphi WM_COPYDATA 消息
    VC Delphi WM_COPYDATA
    DELPHI实现键盘勾子
    设置window任务管理器是否可用
    VS2005 MFC使用
    隐藏显示任务栏
    DELPHI实现键盘勾子
    MSN、腾讯QQ、SKYPE、阿里旺旺网页在线客服源代码
  • 原文地址:https://www.cnblogs.com/muzizongheng/p/3169439.html
Copyright © 2011-2022 走看看