日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

【原创】有关Silverlight中“DataGrid中级联动态绑定父/子ComboBox ”的示例。

發(fā)布時(shí)間:2025/4/16 编程问答 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【原创】有关Silverlight中“DataGrid中级联动态绑定父/子ComboBox ”的示例。 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

嘗試了很多種方案,由于Datagrid動(dòng)態(tài)生成的每行父子comboBox的Name的不確定性,給父ComboBox綁定事件中獲取 子ComboBox很難根據(jù)Name獲取到。

花了不少時(shí)間和公司同事商討,最終方案如下:

注:父子combobox分別代表: 主行業(yè)/子行業(yè)

private void CurrentRowIndusrtylist_SelectionChanged(object sender, SelectionChangedEventArgs e){ComboBox combobox = sender as ComboBox;//獲取另一個(gè)conbox控件CurrentRowIndusrtylist = (sender as ComboBox);if (CurrentRowIndusrtylist != null){ DataGridCell dg = (DataGridCell)(CurrentRowIndusrtylist.Parent);//關(guān)鍵用法if (DataGridRow.GetRowContainingElement(dg) != null){ CurrentRowIndusrtySublist = this.dataGrid9.Columns[3].GetCellContent(DataGridRow.GetRowContainingElement(dg)) as ComboBox;//關(guān)鍵用法if (CurrentRowIndusrtySublist != null) BindSubIndusrtyCodes();//動(dòng)態(tài)去綁定子combobox}}}private void BindSubIndusrtyCodes(){if (CurrentRowIndusrtylist.SelectedItem != null){var unitIndusrtyItem = CurrentRowIndusrtylist.SelectedItem as System_IndustryCodes;_db.Load(_db.GetIndustryCodesQuery(), op =>{CurrentRowIndusrtySublist.Items.Clear();CurrentRowIndusrtySublist.Items.Add(new System_IndustryCodes { ID = -1, IndustryCodes = "--請(qǐng)選擇子行業(yè)--" });IEnumerable<System_IndustryCodes> tempsubList = op.Entities.Where(q => q.ParentCodeID == unitIndusrtyItem.ID);foreach (var temp in tempsubList){if (temp == null)return;CurrentRowIndusrtySublist.Items.Add(new System_IndustryCodes { ID = temp.ID, IndustryCodes = temp.IndustryCodes });}CurrentRowIndusrtySublist.DisplayMemberPath = "IndustryCodes";CurrentRowIndusrtySublist.SelectedValuePath = "ID";CurrentRowIndusrtySublist.UpdateLayout();if (CurrentRowIndusrtySublist.Items.Count == 1)CurrentRowIndusrtySublist.SelectedIndex = 0;elseCurrentRowIndusrtySublist.SelectedIndex = 1;//if (_OldSubindustryId != 0)//CurrentRowIndusrtySublist.SelectedItem = (from q in CurrentRowIndusrtySublist.Items where (q as System_IndustryCodes).ID == _OldSubindustryId select q).FirstOrDefault();//默認(rèn)選擇項(xiàng)-子行業(yè)}, null);}}

?

最終效果:

轉(zhuǎn)載于:https://www.cnblogs.com/x-poior/p/4897353.html

總結(jié)

以上是生活随笔為你收集整理的【原创】有关Silverlight中“DataGrid中级联动态绑定父/子ComboBox ”的示例。的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。