代码之家  ›  专栏  ›  技术社区  ›  dariusriggins

将Setter的值设置为Attached属性

  •  0
  • dariusriggins  · 技术社区  · 16 年前

    <DataTrigger Binding="{Binding Path=IsDisabled}" Value="True">
        <Setter TargetName="LayoutRoot" Property="Opacity" Value="0.3" />
        <Setter TargetName="LayoutRoot" Property="Background" Value="Interaction:Behaviors.OriginalBgBrush" />
    </DataTrigger>
    

    <ControlTemplate x:Key="StandardRowStyle" TargetType="tk:DataGridRow">
        <Border x:Name="LayoutRoot" Margin="0,0,0,-1" MinHeight="23" Interaction:Behaviors.OriginalBgBrush="{TemplateBinding Background}" PreviewMouseRightButtonDown="DataGridRow_SimpleMouseDown" PreviewMouseLeftButtonDown="DataGridRow_SimpleMouseDown" Background="{TemplateBinding Background}" BorderBrush="{StaticResource ElementBorderBrush}" BorderThickness="1" CornerRadius="0" SnapsToDevicePixels="True">
            <toolkit:SelectiveScrollingGrid x:Name="DGR_SelectiveScrollingGrid">
                <toolkit:SelectiveScrollingGrid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="*"/>
                </toolkit:SelectiveScrollingGrid.ColumnDefinitions>
    
                <toolkit:SelectiveScrollingGrid.RowDefinitions>
                    <RowDefinition Height="*" MinHeight="23"/>
                    <RowDefinition Height="Auto"/>
                </toolkit:SelectiveScrollingGrid.RowDefinitions>
    
                <toolkit:DataGridCellsPresenter Grid.Column="1" Grid.Row="0" x:Name="DGR_CellsPresenter" ItemsPanel="{TemplateBinding ItemsPanel}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                <toolkit:DataGridDetailsPresenter Grid.Column="1" Grid.Row="1" Visibility="{TemplateBinding DetailsVisibility}" toolkit:SelectiveScrollingGrid.SelectiveScrollingOrientation="{Binding Path=AreRowDetailsFrozen, Converter={x:Static tk:DataGrid.RowDetailsScrollingConverter}, ConverterParameter={x:Static tk:SelectiveScrollingOrientation.Vertical}, RelativeSource={RelativeSource AncestorType={x:Type tk:DataGrid}}}" />
                <!--<toolkit:DataGridRowHeader Grid.Column="2" Grid.RowSpan="2" toolkit:SelectiveScrollingGrid.SelectiveScrollingOrientation="Vertical" Visibility="{Binding Path=HeadersVisibility, Converter={x:Static tk:DataGrid.HeadersVisibilityConverter}, ConverterParameter={x:Static tk:DataGridHeadersVisibility.Row}, RelativeSource={RelativeSource AncestorType={x:Type tk:DataGrid}}}"/>-->
            </toolkit:SelectiveScrollingGrid>
        </Border>
        <ControlTemplate.Triggers>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsMouseOver" Value="True" />
                    <Condition Property="IsSelected" Value="False" />
                    <Condition Property="DetailsVisibility" Value="Collapsed" />     
                </MultiTrigger.Conditions>
                <Setter TargetName="LayoutRoot" Property="Background" Value="{StaticResource InactiveSelectedBackgroundBrush}" />
                <Setter TargetName="LayoutRoot" Property="BorderBrush" Value="{StaticResource InactiveOuterBorderBrush}" />
                <Setter TargetName="LayoutRoot" Property="CornerRadius" Value="5" />
            </MultiTrigger>            
            <DataTrigger Binding="{Binding Path=IsDisabled}" Value="True">
                <Setter TargetName="LayoutRoot" Property="Opacity" Value="0.3" />
                <!-- Background needs to be changed back to default here -->
            </DataTrigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>
    
    1 回复  |  直到 16 年前
        1
  •  1
  •   itowlson    16 年前

    只需使用ElementName绑定:

    <Setter TargetName="LayoutRoot"
            Property="Background"
            Value="{Binding Path=(Interaction:Behaviors.OriginalBgBrush), ElementName=LayoutRoot}" />
    
    推荐文章