私の WPF アプリケーションには、単一のウィンドウが含まれていますListBox
。ウィンドウのビュー モデルには、ObservableCollection
オブジェクトの が含まれていDomainViewModel
ます。
ウィンドウは以下を定義しますDataTemplate
。
<DataTemplate x:Key="DomainTemplate" DataType="DomainViewModel">
<Border BorderBrush="{Binding Converter={StaticResource BrushConverter}, Path=IsSelected}"
BorderThickness="2"
Name="SelectedBorder">
<Button Click="SelectDomain_Click"
Content="{Binding Path=Name}"
FontSize="16"
FontWeight="Bold"
Height="60"
HorizontalAlignment="Stretch" />
</Border>
</DataTemplate>
ListBox
の宣言は次のとおりです。
<ListBox FontSize="16"
FontWeight="Bold"
Grid.Row="2"
ItemsSource="{Binding Path=Domains}"
ItemTemplate="{StaticResource DomainTemplate}"
Name="DomainListBox" />
ウィンドウがレンダリングされると、各ボタンは Content プロパティにテキストを表示するのにちょうど十分な幅になります。しかし、それは私が望むものではありません。各ボタンを の幅にしたいのですがListBox
、これはウィンドウ自体の幅によって異なります。
Buttons
幅を幅に設定するにはどうすればよいListBox's
ですか?