【问题标题】:How to set the background using acrylic brush through C# in UWP?如何在 UWP 中通过 C# 使用丙烯酸笔刷设置背景?
【发布时间】:2019-02-27 14:26:50
【问题描述】:

我尝试了以下方法:

{
    ContentDialog dialog = new ContentDialog()
    {
        Title = title,
        Content = text,
        CloseButtonText = closeButtonText
    };
    
    dialog.Background = new AcrylicBrush()
    {
        BackgroundSource = 0,
        TintOpacity = 0.5,
        Opacity = 0.5,  
    };
    
    await dialog.ShowAsync();
}

附: - 对不起俄语和我糟糕的英语。提前谢谢你????

【问题讨论】:

    标签: c# uwp


    【解决方案1】:

    如果您可以在内容对话框后看到按钮,则您的代码很好。

    我不使用亚克力画笔的代码。

        private async void Button_OnClick(object sender, RoutedEventArgs e)
        {
            var title = "title";
            var text = "text";
            var closeButtonText = "close";
    
            ContentDialog dialog = new ContentDialog()
            {
                Title = title,
                Content = text,
                CloseButtonText = closeButtonText
            };           
    
            dialog.Background = new SolidColorBrush(Color.FromArgb(255, 202, 24, 37));
    
            await dialog.ShowAsync();
        }
    

    我使用亚克力画笔的代码。

        private async void Button_OnClick(object sender, RoutedEventArgs e)
        {
            var title = "title";
            var text = "text";
            var closeButtonText = "close";
    
            ContentDialog dialog = new ContentDialog()
            {
                Title = title,
                Content = text,
                CloseButtonText = closeButtonText
            };
    
            if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent(
                "Windows.UI.Xaml.Media.XamlCompositionBrushBase"))
            {
                // check that this API is available on the user’s machine
                dialog.Background = new AcrylicBrush()
                {
                    BackgroundSource = Windows.UI.Xaml.Media.AcrylicBackgroundSource.HostBackdrop,
                    TintOpacity = 0.5,
                    FallbackColor = Color.FromArgb(255, 202, 24, 37),
                    Opacity = 0.5,
                };
            }
    
            await dialog.ShowAsync();
        }
    

    Acrylic material - Windows UWP applications

    Customize Acrylic Brush in UWP Applications

    【讨论】:

      猜你喜欢
      • 2018-07-29
      • 1970-01-01
      • 1970-01-01
      • 2020-11-08
      • 2017-11-15
      • 2013-05-30
      • 1970-01-01
      • 1970-01-01
      • 2016-01-06
      相关资源
      最近更新 更多