具体表现,无论ContentDialog中的content宽度如何变化,其最大宽度受到限制,无法显示全部内容。
根本原因,ContentDialog有个默认的最大宽度值(有资料说是542,未验证),在创建contentdialog时用代码设置实测不起作用,在App.axaml里面设定一下即可。
|
1 2 3 4 5 |
<Application.Resources> <ResourceDictionary> <x:Double x:Key="ContentDialogMaxWidth">800</x:Double> </ResourceDictionary> </Application.Resources> |
以上方法将对所有应用ContentDialog的组件生效。你也可以只针对ContentDialog本身设置:
|
1 2 3 4 5 6 |
<ContentDialog> <ContentDialog.Resources> <x:Double x:Key="ContentDialogMaxWidth">1200</x:Double> </ContentDialog.Resources> <!-- Your content here --> </ContentDialog> |