C#WPF触发器不会更改属性

时间:2019-05-14 16:40:37

标签: wpf triggers background grid styles

我目前正在尝试通过触发器更改网格背景。 但是我只是无法使其正常工作。例如,由于某种原因,只有背景不起作用,例如不透明度才起作用。 触发器:

<Style x:Key="WindowFlat" TargetType="{x:Type Grid}">
            <Style.Triggers>
                <Trigger Property="IsFocused" Value="true">
                    <Setter Property="Background" Value="#007ACC"></Setter>
                </Trigger>
            </Style.Triggers>

</Style>

网格:

<Grid Background="#FF333337" >
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>
                <ListView x:Name="ListView1" Height="305" VerticalAlignment="Top" Background="#FF252526" BorderBrush="#FF3F3F46" SnapsToDevicePixels="True" Foreground="White" ItemContainerStyle="{StaticResource FlatListViewItem}" VerticalContentAlignment="Bottom" HorizontalAlignment="Left" Width="175"  
                 Margin="0,20,0,0" BorderThickness="0"  
                 >


                    <ListView.View>
                        <GridView AllowsColumnReorder="False" ColumnHeaderContainerStyle="{StaticResource ResourceKey=myHeaderContainer}">




                            <GridViewColumn  Header="Slot" Width="40"
                                    HeaderContainerStyle="{StaticResource myHeaderStyle}"
                                    HeaderTemplate="{StaticResource myHeaderTemplate}"
                                    DisplayMemberBinding="{Binding Slot}"
                       />


                            <GridViewColumn  Header="Savefile" Width="100"
                                     HeaderContainerStyle="{StaticResource myHeaderStyle}"
                                     HeaderTemplate="{StaticResource myHeaderTemplate}"
                                     DisplayMemberBinding="{Binding Savefile}"/>
                        </GridView>
                    </ListView.View>
                </ListView>
                <Label Content="Current Save's:" HorizontalAlignment="Left" VerticalAlignment="Top" Height="20" Foreground="White" RenderTransformOrigin="0.605,0.097" Padding="2,0,5,5" FontSize="10" VerticalContentAlignment="Center"/>
            </Grid>
        </Border>
    </Grid>

0 个答案:

没有答案