Split control, dimming the contents with the panel open

In the application, I have a Split View control with a panel and content. I would like to know if it is possible to darken the content when the panel is open, as if I applied a 75% opacity mask to splitview.Content.

Thank you in advance for your help.

Hi

+4
source share
1 answer

There are several options:

  • Apply fake opacity by setting a translucent dark control (for example, Grid) as the top layer SplitView.Content.

  • Grid SplitView.Content, Grid ( - ), .

Xaml:

<SplitView.Content>
    <Grid Background="Black">
        <Grid
            x:Name="OpacityGrid"
            Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
            Opacity="1">
        ...
        </Grid>
    </Grid>
</SplitView.Content>
  • SplitView.Content. , 1 .

, Opacity ( 1) SplitView.Pane. :

private void HamburgerButton_Click(object sender, RoutedEventArgs e)
{
    MySplitView.IsPaneOpen = !MySplitView.IsPaneOpen;
    OpacityGrid.Opacity = MySplitView.IsPaneOpen ? 0.7 : 1;
}

:

public class BoolToOpacityConverter : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, string language)
    {
        if (value is bool && (bool) value)
            return 0.7;
        return 1;
    }

    public object ConvertBack(object value, Type targetType, object parameter, string language)
    {
        throw new NotImplementedException();
    }
}

XAML:

<Grid
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
    Opacity="{Binding IsPaneOpen, ElementName=MySplitView, Converter={StaticResource BoolToOpacityConverter}}" />


: PaneOpened , , no PaneOpened.

+1

Source: https://habr.com/ru/post/1661335/


All Articles