Answered WPF BINDING TO STATIC MEMBERS

  • Monday, August 25, 2008 1:34 PM
     
     
    Hi all,

    I have a problem :-<....I have a class with 20 static members. I need to display all this members into some comboboxes from a table.(So this table's items are comboboxes that all list those 20 members ). my question is...it exist a way to bind my 20 members direct to the comboboxes? Thank in adnave

All Replies

  • Monday, August 25, 2008 1:48 PM
     
     Answered
    <ComboBox>
    <!--- Binding to the static member of DataObject class.
    local is custom namespace mapping.
     -->
    <TextBlock Text ="{Binding Source={x:Static local:DataObject.MyData}}"/>
    </ComboBox>

    You can also combine all your data members to one IEnumerable derived class. Then the ComboBox.ItemsSource to collection object.

    Hope this helps.

    Yiling, MVP(Visual C++)
    • Marked As Answer by Marco Zhou Friday, August 29, 2008 7:10 AM
    •  
  • Tuesday, June 09, 2009 3:22 PM
     
     
    This has helped me no end - it is amazing how little WPF info there is for some topics!  Many thanks
  • Thursday, July 16, 2009 6:46 AM
     
     
    Thanks a lot! It worked!
  • Wednesday, February 17, 2010 11:38 PM
     
     
    I have a simpler way of localizing your app using attached properties. You can see this at: http://ashishkaila.blogspot.com/2010/02/localization-made-easy-in-wpf.html