'Content Dialog not showing up WINUI3
I'm trying to show a popup to edit a brand in my app but it doesn't show up.
Function where I call the 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>
Code-behind:
namespace xizSoft.ContentDialogs
{
public sealed partial class EditBrandDialog : ContentDialog
{
public Brand _brand {get; set;}
public EditBrandDialog(Brand brand)
{
this.InitializeComponent();
this.DataContext = _brand = brand;
}
}
}
I've already tryied do debug and the content dialog is being called so I dont know why it isn't showing up.
Solution 1:[1]
Make sure that the SubheaderTextBlockStyle
resource is in scope and that you set the XamlRoot
property of the ContentDialog
:
private async Task EditBrandAsync(Brand brand)
{
var dialog = new ContentDialogs.EditBrandDialog(brand);
dialog.XamlRoot = this.Content.XamlRoot;
await dialog.ShowAsync();
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | mm8 |