void InitComboBox() { srv = WcfProxy.GetProxy; srv.GetAllLotteryInfoCompleted += (s, er) => { loadingProgress.IsBusy = false; if (er.Result.Count == 0) { MessageBox.Show("无彩种数据,该页面无法使用!"); btnSearch.IsEnabled = false; tabItem0.IsEnabled = false; tabItem1.IsEnabled = false; return; } List<LotteryInfo> list = er.Result.ToList(); list.Insert(0, new LotteryInfo() { LotteryTypeID=0, LotteryName="*[正向]", Orientation=0 }); var c = list.Where(p => p.Orientation == 1).FirstOrDefault(); list.Insert(list.IndexOf(c), new LotteryInfo() { LotteryTypeID = 0, LotteryName = "*[逆向]", Orientation = 1 }); this.cbxLottery.ItemsSource = list; this.cbxLottery.DisplayMemberPath = "LotteryName"; this.cbxLottery.SelectedValuePath = "LotteryTypeID"; this.cbxLottery.Tag = list; this.cbxLottery.SelectedIndex = 0; cbxReverseIndex = list.IndexOf(c) - 1; cbxLottery.DropDownOpened += (se, erg) => { this.cbxLottery.UpdateLayout(); this.cbxLottery.ItemContainerGenerator.ContainerFromIndex(0).SetValue( ComboBoxItem.ForegroundProperty, new SolidColorBrush(Colors.Blue)); this.cbxLottery.ItemContainerGenerator.ContainerFromIndex(list.IndexOf(c)-1) .SetValue(ComboBoxItem.ForegroundProperty, new SolidColorBrush(Colors.Red)); }; LoadPositive(); }; loadingProgress.IsBusy = true; srv.GetAllLotteryInfoAsync(); }
void InitComboBox() { srv = WcfProxy.GetProxy; srv.GetAllLotteryInfoAsync(); loadingProgress.IsBusy = true; srv.GetAllLotteryInfoCompleted += (s, e) => { loadingProgress.IsBusy = false; List<LotteryInfo> lottery = e.Result.ToList(); lottery.Insert(0, new LotteryInfo() { LotteryName="请选择", LotteryTypeID=0 }); this.cbxLottery.ItemsSource = lottery; this.cbxLottery.DisplayMemberPath = "LotteryName"; this.cbxLottery.SelectedValuePath = "LotteryTypeID"; this.cbxLottery.SelectedIndex = 0; //srv.GetAllPlayTypeInfoAsync(); List<PlayTypeInfo> playtype = new List<PlayTypeInfo>(); playtype.Insert(0, new PlayTypeInfo() { PlayTypeName = "请选择", PlayTypeID = 0 }); this.cbxPlayType.ItemsSource = playtype; this.cbxPlayType.DisplayMemberPath = "PlayTypeName"; this.cbxPlayType.SelectedValuePath = "PlayTypeID"; this.cbxPlayType.SelectedIndex = 0; }; //srv.GetAllPlayTypeInfoCompleted += (s, e) => //{ //}; }