s 这个问题的一个版本已经被问过here https://stackoverflow.com/questions/30751663/how-to-change-mahapps-metro-dialog-content-template-width.
我认为答案是清晰简洁的,但我不太明白,而且我认为我不应该开始大量评论试图弄清楚(正如发布的那样是正确的礼仪)here https://meta.stackexchange.com/questions/139282/i-dont-understand-an-answer-should-i-add-a-comment-or-post-a-new-question)
我想在 MahApps.Metro 对话框中添加一个额外的按钮。我需要一个浏览按钮,以便用户可以输入目录。This https://stackoverflow.com/questions/30751663/how-to-change-mahapps-metro-dialog-content-template-width答案显示了如何做到这一点,但我不太明白,因为我对 C# 和 WPF 相当陌生。
我不明白的是我应该在 xaml 文件中放置<Style></Style>
部分。
如果我的猜测是正确的,它可以去我之外的任何地方<Grid></Grid>
然后我收到了我不明白的错误。
我当前的代码 .xaml 文件。
<Controls:MetroWindow x:Class="testApp.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
xmlns:Dialogs="clr-namespace:MahApps.Metro.Controls.Dialogs"
Title="testApp" Height="auto" Width="auto"
EnableDWMDropShadow="True"
ResizeMode="CanResizeWithGrip"
WindowTransitionsEnabled="False"
WindowStartupLocation="CenterScreen" Loaded="OnLoaded">
<Grid>
<!--some content -->
</Grid>
</Controls:MetroWindow>
如果我在网格部分上方插入样式部分,则会出现错误The namespace "Dialog" is not defined
我以为是xmlnsxmlns:Dialogs="clr-namespace:MahApps.Metro.Controls.Dialogs"
应该添加对话框吗?
一旦我能够获得样式集,我想我只需添加之前答案中的以下代码(带有我想要的按钮)。
<Dialogs:CustomDialog x:Key="CustomDialogTest"
Style="{StaticResource NewCustomDialogStyle}"
Title="This dialog allows arbitrary content. It will close in 5 seconds."
x:Name="CustomTestDialog">
<StackPanel>
<TextBlock Height="30"
Text="This dialog allows arbitrary content. You have to close it yourself by clicking the close button below."
TextWrapping="Wrap"
Foreground="{DynamicResource AccentColorBrush}" />
<Button Content="Close Me!" />
</StackPanel>
</Dialogs:CustomDialog>
我不明白什么?提前致谢
Note
我没有添加我的 .cs 代码 b/c 实际上显示标准异步对话框没有问题。