locked
Very basic binding question RRS feed

  • Question

  • Hi, I've read a whole bunch of tutorials on data binding, and I just can't it to do what I want.

    I have a class, that inherits from Window

    This window defines a statusbar:
    <StatusBar DataContext = "">
        <StatusBarItem>
            <Binding Path = "Property1"/>
        </StatusBarItem>
        <StatusBarItem>
            <Binding Path = "Property2"/>
        </StatusBarItem>
    </StatusBar>

    The window have 2 properties, called Property1 and Property2 to make it simple.
    What do I put into DataContext? (this, which I found logical, doesn't work)
    Do the Properties need to be DependencyProperties?
    Must the class implement INotifyPropertyChanges?
    Must the Property setter {} do OnPropertyChange("Property1");?

    Is there anything else I have missed?

    I feel like I've tried everything I can think of from every tutorial I could read, and I just don't get this basic thing, help would be appreciated. :)

    http://www.catb.org/~esr/faqs/smart-questions.html#intro
    Thursday, August 21, 2008 11:43 AM

Answers

  •  Hi Letharion

    What do I put into DataContext? any thing.

    Do the Properties need to be DependencyProperties? no

    Must the class implement INotifyPropertyChanges? if you want the StatusBarItem reflect the Property1 changes, answer is yes

    Must the Property setter {} do OnPropertyChange("Property1");? if you want the StatusBarItem reflect the Property1 changing, answer is yes

    Is there anything else I have missed? looks the answer is yes, suggest u to read the binding topics on msdn carefully



    hope that helps


    thanks

    珍惜生命,远离美女
    • Marked as answer by Letharion Thursday, August 21, 2008 12:09 PM
    • Marked as answer by Letharion Thursday, August 21, 2008 12:09 PM
    Thursday, August 21, 2008 12:04 PM