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>
    
  • 相关阅读:
    获取缓存文件大小并清理 By HL
    iOS 模糊、精确搜索匹配功能方法总结 By HL
    让 iOS 设备 “说出” 你想说的话!! #DF
    自定义索引--秀清
    云端iclound使用-陈棚
    IM开发之Socket通信开源类库CocoaAsyncSocket
    iOS App 架构文章推荐
    IM开发通信协议基础知识(一)---TCP、UDP、HTTP、SOCKET
    [手游项目5]windows获得当前进程名
    【软件安装】c++11安装
  • 原文地址:https://www.cnblogs.com/muzizongheng/p/3169439.html
Copyright © 2011-2022 走看看