Binding to what property? (on the listbox I mean) SelectedItem? Hmm... surely it couldn't be that simple? bet it is... will try it out and let you know.
On Fri, Mar 20, 2009 at 8:37 AM, Jordan Knight <[email protected]>wrote: > If it were me I'd be two way binding on SelectedItem... > > > > *From:* [email protected] [mailto: > [email protected]] *On Behalf Of *Stephen Price > *Sent:* Friday, 20 March 2009 2:28 AM > *To:* [email protected] > *Subject:* Re: Set value on combobox > > > > Ooooer, I like that. I'll have a look at that tomorrow. > > > > I ended up with a work around. The combobox is not visible until the user > clicks the edit button, and the stackpanel those controls are in are made > visible, so I'm using the same method load the required value. > > > > As for MVVM, I like the idea but changing the design at this stage would be > a lot of work and I'm still learning about it. Binding to a property was > going to be my next thing to try until I thought of putting it on the "edit" > method. > > > > thanks for the tips, much appreciated! > > > > cheers, > > Stephen > > On Thu, Mar 19, 2009 at 9:17 PM, Miguel Madero <[email protected]> > wrote: > > When you set the DataContext, the first time the items are loaded the > control will select the first item in the list. You can subscribe to the > SelectedItemChanged event, then in the same method unsubscribe and set the > default. > > > > public void SetDefaultValue(object o, EventArgs e) > > { > > ((ComboBox)o).SelectedItemChanged-= SetDefaultValue; > > ((ComboBox)o).SelectedItem = "SomethingElse" > > } > > > > You can also consider using MVVM and bind the SelectedItem Property of the > ComboBox to a property of your ViewModel > ------------------------------ > > Support procedure: https://www.codify.com/lists/support > List address: [email protected] > Subscribe: [email protected] > Unsubscribe: [email protected] > List FAQ: http://www.codify.com/lists/ozsilverlight > Other lists you might want to join: http://www.codify.com/lists > > > ------------------------------ > > Support procedure: https://www.codify.com/lists/support > List address: [email protected] > Subscribe: [email protected] > Unsubscribe: [email protected] > List FAQ: http://www.codify.com/lists/ozsilverlight > Other lists you might want to join: http://www.codify.com/lists > ------------------------------ > Support procedure: https://www.codify.com/lists/support > List address: [email protected] > Subscribe: [email protected] > Unsubscribe: [email protected] > List FAQ: http://www.codify.com/lists/ozsilverlight > Other lists you might want to join: http://www.codify.com/lists > -------------------------------------------------------------------------------- Support procedure: https://www.codify.com/lists/support List address: [email protected] Subscribe: [email protected] Unsubscribe: [email protected] List FAQ: http://www.codify.com/lists/ozsilverlight Other lists you might want to join: http://www.codify.com/lists
