WPFでチェックボックスを使用してListBoxを作成したい場合、単純な文字列値で "Content"値をデータバインドする必要があります。しかし、私が試みると<CheckBox Margin="5" Content="{Binding}" />
アプリがクラッシュします。DataTind to DataTemplatedチェックボックス
これは私が持っているものです。あなたが無限に再帰するDataTemplateを作成し
<ListBox Grid.Row="1" IsSynchronizedWithCurrentItem="True" x:Name="drpReasons">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal" >
</WrapPanel>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.Resources>
<DataTemplate DataType="{x:Type System:String}">
<CheckBox Margin="5" Content="{Binding}" />
</DataTemplate>
</ListBox.Resources>
</ListBox>
それはあなたの特定の問題の一部ではないのですが、あなたは同様にTrueにWrapPanelのIsItemsHostプロパティを設定する必要があります。
あなたは明示的にチェックボックスの内側のTextBlockを置くことによってそれを修正することができます。 –
Schweet!その小さなおかげでありがとう。 – Russ