Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
248 views
in Technique[技术] by (71.8m points)

silverlight - How to update combobox value on changing selection c# dynamically using Binding() in c# (not xaml)

I am c# silverlight5 beginner and i have a situation that i have to created a combo box dynamically using c# and kept items in it. But the problem now when i run it run properly showing the last value by default but when i select the another value it don't update the that value in the text box near by because it is not working dynamically.

I guess i need to add some selection changed or some other event using c#. But i dont know how to do that. Please note that i have created this combo box using c# only.

How to change the value in correspondng selection to the combobox value ?(just using c#)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Just when creating the combobox, create also the binding in c#, then it will update the textbox automatically without the need for any events or additional code.

  var binding = new Binding("Text");
  binding.Source = cb;
  binding.StringFormat = "{0} millions";
  txtblk2.SetBinding(TextBlock.TextProperty, binding);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...