我们正在努力遵循这些准则。为此,我想设置应用程序级别的样式或属性来设置控件之间的边距。
我无法通过样式设置边距,因为它要求我输入目标对象,并且可能存在我不想遵循上述内容的情况。
我可以通过在 App.xaml.cs 中创建一些 getter 属性来设置边距
/// <summary>
/// Gets the margin to be set all around the dialog
/// </summary>
public Thickness MarginsAllAroundDialog
{
get
{
// returns default margin
return new Thickness(7);
}
}
并将对话框的边距设置为:
<Window x:Class="XXX.Views.MainWindow"
x:Name="mainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:prism="http://www.codeplex.com/prism"
Title="MainWindow"
Margin="{Binding Path=MarginsAllAroundDialog, Source={x:Static Application.Current}}"
Height="350"
Width="525"
WindowState="Maximized">
这是正确的方法还是我们通过更简单的方法实现相同的方法。