我想问你是否有可能在将出现ListBoxItem
的字符串和要存储在 DB 中的值中提供。这确实是可能的:
ItemSource={Binding MyEnumColleciton}
或者
ItemSource={DynamicResource MyCollection}
ETC..
但是如果你想象我有大约 100 个 ListBoxes .. 我不想有这么多不同的枚举和其他 ItemSource 集合,我想将它直接写入 ListBoxItem。
这就是我所说的:
<ListBox SelectedItem="{Binding Path=MyPath1}" Style="{StaticResource RadioButtonList}">
<ListBoxItem Content="Text1" />
<ListBoxItem Content="Text2" />
</ListBox>
<ListBox SelectedItem="{Binding Path=MyPath2}" Style="{StaticResource RadioButtonList}">
<ListBoxItem Content="Text3" />
<ListBoxItem Content="Text4" />
</ListBox>
<ListBox SelectedItem="{Binding Path=MyPath3}" Style="{StaticResource RadioButtonList}">
<ListBoxItem Content="Text5" />
<ListBoxItem Content="Text6" />
</ListBox>
... 100x