私たちはこれらのガイドラインに従おうとしています。このために、アプリケーションレベルのスタイルまたはプロパティを設定して、コントロール間のマージンを設定します。
ターゲットオブジェクトを要求されるため、スタイルでマージンを設定できません。また、上記に従わない場合もあります。
App.xaml.csでいくつかのゲッタープロパティを作成することでマージンを設定できます
/// <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">
これは正しい方法ですか、それとももっと簡単な方法で同じことを達成しますか。