gpt4 book ai didi

c# - 内容对话框不显示 WINUI3

转载 作者:行者123 更新时间:2023-12-05 01:29:03 37 4
gpt4 key购买 nike

我试图在我的应用中显示一个弹出窗口来编辑品牌,但它没有显示。

调用对话框的函数:

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;
}
}
}

我已经尝试过调试并且正在调用内容对话框,所以我不知道为什么它没有出现。

最佳答案

确保 SubheaderTextBlockStyle 资源在范围内并且您设置了 ContentDialogXamlRoot 属性:

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

关于c# - 内容对话框不显示 WINUI3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68066397/

37 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com