none
WPF BINDING TO STATIC MEMBERS

    Question

  • 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
    Monday, August 25, 2008 1:34 PM

Answers

  • <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
    Monday, August 25, 2008 1:48 PM

All replies

  • <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
    Monday, August 25, 2008 1:48 PM
  • This has helped me no end - it is amazing how little WPF info there is for some topics!  Many thanks
    Tuesday, June 09, 2009 3:22 PM
  • Thanks a lot! It worked!
    Thursday, July 16, 2009 6:46 AM
  • 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
    Wednesday, February 17, 2010 11:38 PM