使用固定ComboxItem 无法通过 selectitem as object 来进行回去到 Content内的对香数据。那我只能这个样干:
csharp
private void CBPaiweiLeixingSelect_Change(object sender, SelectionChangedEventArgs e)
{
ComboBox ThisBox = sender as ComboBox;
List<EDaxiaosuixi> ListShuixiE;
ComboBoxItem SelectItemTextBox = CBPaiweiType.SelectedItem as ComboBoxItem;
string SelectItemstr = SelectItemTextBox.Content as string;
if (SelectItemstr == "非吉祥牌位")
{
ListShuixiE = ThisPaiweilist.Where(x => x.PaiweiType != EPaiweiType.吉祥牌位).Select(x => x.DaxiaoSuixi).Distinct().ToList();//获取大小随喜
CBPaiweiGuige.ItemsSource = ListShuixiE;
}
else if (SelectItemstr == "吉祥牌位")
{
ListShuixiE = ThisPaiweilist.Where(x => x.PaiweiType == EPaiweiType.吉祥牌位).Select(x => x.DaxiaoSuixi).Distinct().ToList();//获取大小随喜
CBPaiweiGuige.ItemsSource = ListShuixiE;
}
}
使用这个方法:
csharp
List<EDaxiaosuixi> ListShuixiE;
ComboBoxItem SelectItemTextBox = CBPaiweiType.SelectedItem as ComboBoxItem;
string SelectItemstr = SelectItemTextBox.Content as string;
SelectItemstr 就是要获取的便跟过来的数据。