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>
    
  • 相关阅读:
    thinkphp分页样式css代码
    thinkphp两表,多表联合查询及分页的连贯操作写法
    ThinkPHP3.2.3新特性之:数据库设置
    ThinkPHP的主从数据库配置
    CentOS7 64位下MySQL5.7安装与配置(YUM)
    sessionid如何产生?由谁产生?保存在哪里?
    GIT使用
    Windows下安装composer
    树莓派debian配置lamp[解决Apache不显示php网页]
    【Linux】Debian 下安装 Apache,MySQL,PHP
  • 原文地址:https://www.cnblogs.com/muzizongheng/p/3169439.html
Copyright © 2011-2022 走看看