Miguel Madero
Fri, 31 Oct 2008 04:53:52 -0700
Make sure that the object is already in the ItemsSource. The combo can only select items that are part of the collection they're bound to.
ddl.DataContext = MyCollection; // or
dll.ItemsSource
ddl.SelectedItem = new MyClass(); // Won't work
because MyClass is not part of the collection
ddl.SelectedItem = MyCollection[0]; // J
The order is also important so this won't work either.
ddl.SelectedItem = MyCollection[0]; // J
ddl.DataContext = MyCollection; // or
dll.ItemsSource
Similarly in XAML if you're databinding the properties
<Combo SelectedItem={Binding SomeProperty}
DataContext={Binding SomeCollection}/>
This won't work because it will try to get the SelectedItem first and then
bind the items, just as in the previous C# example
This will do the trick
<Combo DataContext={Binding SomeCollection}
SelectedItem={Binding SomeProperty} />
Miguel A. Madero Reyes
<http://www.miguelmadero.com/> www.miguelmadero.com (blog)
<[EMAIL PROTECTED]> [EMAIL PROTECTED]
+61 (0) 406-704-161
623/243 Pyrmont Street
Pyrmont, NSW, 2009
Australia
P "Please reconsider your environmental responsibility before printing this
e-mail"
The information in this e-mail is confidential and may be legally
privileged. It is intended solely for the addressee. If you are not the
intended recipient, any disclosure, copying, distribution or any action
taken or omitted to be taken in reliance on it, is prohibited and may be
unlawful.
From: [EMAIL PROTECTED] [EMAIL PROTECTED]
On Behalf Of Muhammad Niaz
Sent: Friday, 31 October 2008 2:55 AM
To: listserver@ozSilverlight.com
Subject: [OzSilverlight] SL Combobox SelectedItem ?
Hi All,
I am working on MS Combox in SL App,
But I have an issue, like ddlMediatype.SelectedItem =
(ContentTypeDTO)innerContentTypeDTO;
Mean I have no success to set SelectedItem through code.
Any details sample code or Article, in which if there are multiple
Comboboxes on each change other reflects. ;)
Thanks & Regards,
Muhammad Niaz
Software Engineer
Intagleo Systems Pvt Ltd
www.intagleo.co.uk
-------------------------------------------------------------------
OzSilverlight.com - to unsubscribe from this list, send a message back to
the list with 'unsubscribe' as the subject.
Powered by mailenable.com - List managed by www.readify.net
-------------------------------------------------------------------
OzSilverlight.com - to unsubscribe from this list, send a message back to the
list with 'unsubscribe' as the subject.
Powered by mailenable.com - List managed by www.readify.net