问题描述
我想做一个框,左边是按钮,点击按钮的时候在右边显示对应的内容,但是这些按钮时每个专业的名称,需要绑定数据库中的名称,请问高手改怎么绑定,谢谢!这是其页面对应的代码:usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Net;usingSystem.Windows;usingSystem.Windows.Controls;usingSystem.Windows.Documents;usingSystem.Windows.Input;usingSystem.Windows.Media;usingSystem.Windows.Media.Animation;usingSystem.Windows.Shapes;usingPetroMentor.Service;usingSystem.Collections.ObjectModel;usingHSE.Common;usingPetroMentor.Service.Common;usingHSE.Common;usingNewtonsoft.Json.Converters;usingPetroMentor.Service.Common;usingNewtonsoft.Json;usingHSE.Events;usingDIST.LR.ZHJG.Events;namespaceHSE{publicpartialclassZXMSelect:ChildWindow{WebClientclient;publicObservableCollection<T_ZRLS_ZRQJCXM_S>ZRQJCXMS{get;set;}publicObservableCollection<T_ZRLS_ZRQJCXM_S>SelectZRQJCXMS{get;set;}publicZXMSelect(){InitializeComponent();this.SelectZRQJCXMS=newObservableCollection<T_ZRLS_ZRQJCXM_S>();client=newWebClient();//在异步资源下载操作完成时发生client.DownloadStringCompleted+=newDownloadStringCompletedEventHandler(client_DownloadStringCompleted_Select);}publicvoidInitZRQJCXM(){Typetype=typeof(T_ZRLS_ZRQJCXM_S);Uriendpoint=newUri(String.Format("{0}QueryHanlder.ashx?{1}={2}&{3}={4}&{5}={6}&{7}={8}&{9}={10}&{11}={12}",SystemVar.ServiceUrl,Consts.MODULE,type.Name,Consts.PAGE_NUMBER,1,Consts.PAGE_SIZE,20000,Consts.WHERE,"1=1",Consts.TABLE,"T_ZRLS_ZRQJCXM",Consts.R,newRandom().NextDouble().ToString()));client.DownloadStringAsync(endpoint);}privatevoidclient_DownloadStringCompleted_Select(objectsender,DownloadStringCompletedEventArgse){try{if(e.Result!=null){CommonQueryInfo<T_ZRLS_ZRQJCXM_S>info=Util.JsonToObject<CommonQueryInfo<T_ZRLS_ZRQJCXM_S>>(e.Result)asCommonQueryInfo<T_ZRLS_ZRQJCXM_S>;if(info!=null&&info.ResultInfos!=null&&info.ResultInfos.Count>0){this.ZRQJCXMS=CollectionExtensions.ToObservableCollection<T_ZRLS_ZRQJCXM_S>(info.ResultInfos);this.lstZrqjcxm.ItemsSource=this.ZRQJCXMS;}}}catch(Exceptionex){MessageBox.Show(string.Format("获取岗位信息发生异常!{0}",ex.Message));//EventAggregatorRepository.EventAggregator.GetEvent<BusyIndicatorEvent>().Publish(newBusyInfo(){IsBusy=false,BusyContent="数据获取中..."});}}privatevoidOKButton_Click(objectsender,RoutedEventArgse){this.DialogResult=true;}privatevoidCancelButton_Click(objectsender,RoutedEventArgse){this.DialogResult=false;}privatevoidRadToggleButton_Checked(objectsender,RoutedEventArgse){Telerik.Windows.Controls.RadToggleButtonbtn=senderasTelerik.Windows.Controls.RadToggleButton;T_ZRLS_ZRQJCXM_Szrq=btn.TagasT_ZRLS_ZRQJCXM_S;if(zrq!=null)this.SelectZRQJCXMS.Add(zrq);}privatevoidRadToggleButton_Unchecked(objectsender,RoutedEventArgse){Telerik.Windows.Controls.RadToggleButtonbtn=senderasTelerik.Windows.Controls.RadToggleButton;T_ZRLS_ZRQJCXM_Szrq=btn.TagasT_ZRLS_ZRQJCXM_S;if(zrq!=null)this.SelectZRQJCXMS.Remove(zrq);}privatevoidbtn_Zjzy_Click(objectsender,RoutedEventArgse){ZXMSelectzrqwin=newZXMSelect();zrqwin.Closed+=(s1,e1)=>{if(zrqwin.DialogResult.HasValue&&zrqwin.DialogResult.Value&&zrqwin.SelectZRQJCXMS!=null){//viewmodel.SaveModel.ZRQJCXMS=zrqwin.SelectZRQJCXMS;}};zrqwin.InitZRQJCXM();}}}
解决方案
解决方案二:
你可以看看msdn上的例子是怎样绑定到StudentName的。
解决方案三:
欢迎提问silverlight/wpf问题。希望.net论坛多一些wpf/silverlight问题,提高初学者UI程序开发的层次。不能只有一些简单的winform问题。
解决方案四:
另外也有很多许多年前的Blend教程,方便于学习这类绑定的(借助美工板)开发操作。例如:
解决方案五:
非常感谢,有不明白的再请教您!