XAML “内容”对话框未显示WINUI3

3qpi33ja  于 2023-08-01  发布在  其他
关注(0)|答案(1)|浏览(122)

我试图显示一个弹出窗口来编辑我的应用程序中的品牌,但它不显示。
调用Dialog的函数:

private async Task EditBrandAsync(Brand brand)
{
    var dialog = new ContentDialogs.EditBrandDialog(brand);
    await dialog.ShowAsync();
}

字符串
ContentDialog XAML:

<ContentDialog
    x:Class="xizSoft.ContentDialogs.EditBrandDialog"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:xizSoft.ContentDialogs"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

    <StackPanel>
        <TextBlock Text="Marca" Style="{StaticResource SubheaderTextBlockStyle}"/>

        <TextBox Header="Nome" Text="{Binding Name}"/>
        <TextBox Header="Logotipo" Text="{Binding LogoFileName}"/>

        <StackPanel>
            <Image Source="{Binding LogoFileName}"/>
        </StackPanel>
    </StackPanel>
</ContentDialog>


代码隐藏:

namespace xizSoft.ContentDialogs
{
  public sealed partial class EditBrandDialog : ContentDialog
    {
        public Brand _brand {get; set;}

        public EditBrandDialog(Brand brand)
        { 
            this.InitializeComponent();
            this.DataContext = _brand = brand;
        }
    }
}


我已经尝试做调试和内容对话框正在调用,所以我不知道为什么它没有显示出来。

f0brbegy

f0brbegy1#

确保SubheaderTextBlockStyle资源在作用域中,并且设置了ContentDialogXamlRoot属性:

private async Task EditBrandAsync(Brand brand)
{
    var dialog = new ContentDialogs.EditBrandDialog(brand);
    dialog.XamlRoot = this.Content.XamlRoot;
    await dialog.ShowAsync();
}

字符串

相关问题