1

我有点奇怪atm。

我要做的第一件事是将我的用户控件的不透明度绑定到带有转换器的布尔属性。我在一个带有小菜单的全屏 WPF 应用程序上。如果菜单打开,其他任何东西都应该得到较低的不透明度。有点灰了一切。

第二件事是菜单不应该从用户控件继承不透明度。

不知道我可以用谷歌搜索什么。我努力寻找有用的东西是徒劳的。希望您能够帮助我。

问候卢卡斯

看法:

<UserControl ....>
...

    <view:InvisibleButtonView Grid.Row="0" Grid.Column="2" 
                            Height="75" Width="75"
                            VerticalAlignment="Top" HorizontalAlignment="Right" />

    <view:IdleScreenView Visibility="{Binding IsWelcomeScreenActive,Converter={StaticResource ResourceKey=NegativeBooleanToVisibilityConverter}}" 
                       Grid.Row="0" Grid.RowSpan="2" Grid.Column="1" 
                       VerticalAlignment="Center"/>

    <view:WelcomeScreenView Visibility="{Binding IsWelcomeScreenActive,Converter={StaticResource ResourceKey=BooleanToVisibilityConverter}}" 
                          Grid.Row="0" Grid.RowSpan="2" Grid.Column="1" 
                          VerticalAlignment="Center"/>

    <view:DateView Grid.Row="2" Grid.Column="1" 
                 VerticalAlignment="Center" />

    <view:InvisibleInputView Height="25" Width="100" Background="Transparent" BorderBrush="Transparent" Cursor=""/>

    <view:MainMenuView Grid.RowSpan="3" Grid.ColumnSpan="3" Visibility="{Binding IsAnyMenuActive, Converter={StaticResource ResourceKey=BooleanToVisibilityConverter}}" 
                         Height="300" Width="250" />

</Grid>

4

1 回答 1

2

帮助我获得了背景视图

<UserControl.Resources>
    <SolidColorBrush x:Key="MenuActiveBackgroundColor" Color="Green"/>
    <SolidColorBrush x:Key="MenuInactiveBackgroundColor" Color="Tomato"/>
</UserControl.Resources>

<Grid>
    <Grid.Style>
        <Style>
            <Style.Triggers>
                <DataTrigger Binding="{Binding AnyMenuIsActive}" Value="true">
                    <Setter Property="Grid.Background" Value="{DynamicResource MenuActiveBackgroundColor}"/>
                </DataTrigger>
                <DataTrigger Binding="{Binding AnyMenuIsActive}" Value="false">
                    <Setter Property="Grid.Background" Value="{DynamicResource MenuInactiveBackgroundColor}"/>
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </Grid.Style>
</Grid>
于 2013-01-04T03:37:40.410 回答