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

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

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

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

字符串
ContentDialog XAML:

  1. <ContentDialog
  2. x:Class="xizSoft.ContentDialogs.EditBrandDialog"
  3. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  4. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  5. xmlns:local="using:xizSoft.ContentDialogs"
  6. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  7. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  8. mc:Ignorable="d"
  9. Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
  10. <StackPanel>
  11. <TextBlock Text="Marca" Style="{StaticResource SubheaderTextBlockStyle}"/>
  12. <TextBox Header="Nome" Text="{Binding Name}"/>
  13. <TextBox Header="Logotipo" Text="{Binding LogoFileName}"/>
  14. <StackPanel>
  15. <Image Source="{Binding LogoFileName}"/>
  16. </StackPanel>
  17. </StackPanel>
  18. </ContentDialog>


代码隐藏:

  1. namespace xizSoft.ContentDialogs
  2. {
  3. public sealed partial class EditBrandDialog : ContentDialog
  4. {
  5. public Brand _brand {get; set;}
  6. public EditBrandDialog(Brand brand)
  7. {
  8. this.InitializeComponent();
  9. this.DataContext = _brand = brand;
  10. }
  11. }
  12. }


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

f0brbegy

f0brbegy1#

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

  1. private async Task EditBrandAsync(Brand brand)
  2. {
  3. var dialog = new ContentDialogs.EditBrandDialog(brand);
  4. dialog.XamlRoot = this.Content.XamlRoot;
  5. await dialog.ShowAsync();
  6. }

字符串

相关问题