■1. 入力画面
サンプル1
<Window
x:Class="Sample1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Sample1"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="MainWindow"
Width="500"
Height="350"
ResizeMode="CanResizeWithGrip"
mc:Ignorable="d">
<Window.Resources>
<!-- 標準ボタンスタイル -->
<Style x:Key="StandardButtonStyle" TargetType="Button">
<Setter Property="Margin" Value="8" />
</Style>
<!-- 既定ボタンスタイル -->
<Style BasedOn="{StaticResource StandardButtonStyle}" TargetType="Button" />
<!-- 遷移ボタンスタイル -->
<Style
x:Key="TransitionButton"
BasedOn="{StaticResource StandardButtonStyle}"
TargetType="Button">
<Setter Property="Width" Value="100" />
</Style>
<!-- 既定ラベルスタイル -->
<Style TargetType="Label">
<Setter Property="Margin" Value="8,8,8,0" />
</Style>
<!-- 標準テキストボックススタイル -->
<Style x:Key="StandardTextBoxStyle" TargetType="TextBox">
<Setter Property="Margin" Value="8,0,8,8" />
</Style>
<!-- 既定テキストボックススタイル -->
<Style BasedOn="{StaticResource StandardTextBoxStyle}" TargetType="TextBox" />
<!-- 小サイズテキストボックススタイル -->
<Style
x:Key="SizeSText"
BasedOn="{StaticResource StandardTextBoxStyle}"
TargetType="TextBox">
<Setter Property="Width" Value="100" />
<Setter Property="HorizontalAlignment" Value="Left" />
</Style>
<!-- 中サイズテキストボックススタイル -->
<Style
x:Key="SizeMText"
BasedOn="{StaticResource StandardTextBoxStyle}"
TargetType="TextBox">
<Setter Property="Width" Value="200" />
<Setter Property="HorizontalAlignment" Value="Left" />
</Style>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<!-- 入力項目エリア -->
<StackPanel>
<Label Content="項目あ(_A)" Target="{Binding ElementName=ItemA}" />
<TextBox x:Name="ItemA" Text="" />
<Label Content="項目い(_B)" Target="{Binding ElementName=ItemB}" />
<TextBox x:Name="ItemB" Text="" />
<Label Content="項目う(_C)" Target="{Binding ElementName=ItemC}" />
<TextBox
x:Name="ItemC"
Style="{StaticResource SizeSText}"
Text="" />
<Label Content="項目え(_D)" Target="{Binding ElementName=ItemD}" />
<TextBox
x:Name="ItemD"
Style="{StaticResource SizeMText}"
Text="" />
</StackPanel>
<!-- ボタンエリア -->
<StackPanel
Grid.Row="1"
HorizontalAlignment="Right"
Orientation="Horizontal">
<Button
Content="OK"
IsDefault="True"
Style="{StaticResource TransitionButton}" />
<Button
Content="キャンセル"
IsCancel="True"
Style="{StaticResource TransitionButton}" />
</StackPanel>
</Grid>
</Window>
■2. パス入力
サンプル2
<Window
x:Class="Sample2.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Sample2"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="MainWindow"
Width="500"
Height="180"
ResizeMode="CanResizeWithGrip"
mc:Ignorable="d">
<Window.Resources>
<!-- 既定ラベルスタイル -->
<Style TargetType="Label">
<Setter Property="Margin" Value="8,8,8,0" />
</Style>
<!-- 既定テキストボックススタイル -->
<Style TargetType="TextBox">
<Setter Property="Margin" Value="8,0,8,8"/>
</Style>
<!-- ボタンスタイル -->
<Style TargetType="Button" x:Key="SubButtonStyle">
<Setter Property="Width" Value="45"/>
<Setter Property="Margin" Value="0,0,8,8"/>
</Style>
</Window.Resources>
<StackPanel>
<Label Content="パス(_P)" Target="{Binding ElementName=PathText}"/>
<DockPanel>
<Button Content="参照" DockPanel.Dock="Right" Style="{StaticResource SubButtonStyle}"/>
<TextBox x:Name="PathText" Text=""/>
</DockPanel>
</StackPanel>
</Window>