我試圖創建一個模式UserControl,因爲ContentDialog控件很難修改。UWP模式用戶控件
How to change background overlay of ContentDialog uwp
標題區將在內容區域(如ContentDialog),但背景應該是一樣的owerlay內容。
我應該怎麼做來創建此模式的用戶控件?編輯: 感謝您的回答! Actualy我有我的控制
<UserControl x:Class="TestModal.ModalView">
<Grid Background="Black" Opacity="0.5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Text="test"/>
</Grid>
</UserControl>
主頁: 的XAML
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Button Click="Show_Click" />
</Grid>
</Page>
C#:
private void Show_Click(object sender, RoutedEventArgs e)
{
ModalView myModalView = new ModalView();
Content = myModalView;
}
但如何激活用戶控件?改變內容不是我想要做的。
如果要在頁面中使用用戶控件,可以在XAML中使用' local:ModalView>'。 –
謝謝,現在我在我的頁面 local:ModalView>中使用,她的可見性是「Collaped」並帶有Click事件,我將可見性設置爲「Visibility.Visible」 –
sasukaru