Misunderstanding about Binding

hi,

I'm trying to bind the Message property of a MessageBoxActivity to the text property of a custom activty.

in messageboxActivity:

public static DependencyProperty MessageProperty = System.Workflow.ComponentModel.DependencyProperty.Register("Message", typeof(string), typeof(MessageActivity));

private string message;

public string Message
{
get { return message; }
set { message = value; }
}

in custom activity:

public static DependencyProperty TextProperty = System.Workflow.ComponentModel.DependencyProperty.Register("Text", typeof(string), typeof(Activity1));


private string _text;

public string Text
{
get { return _text; }
set { _text = value; }
}


but when I bind message to text, the messagebox is empty, whereas i've filled the Text property before compiling and when I use it in conditions or in a code activity, the Text property got the right value

Any idea in this really basic issu

Antoine


Answer this question

Misunderstanding about Binding

  • Nagaraja Subbrayalu

    Your properties are declared incorrectly. The .NET properties should be implemented in terms of the corresponding dependency property, like this:

    public static DependencyProperty MessageProperty = System.Workflow.ComponentModel.DependencyProperty.Register("Message", typeof(string), typeof(MessageActivity));

    public string Message
    {
    get { return (string)base.GetValue(MessageProperty); }
    set { base.SetValue(MessageProperty, value); }
    }



    Likewise for the other one.


  • rxg

    Duh, yeah, fixed it :) That happens for writing code directly into the post :)


  • P Cause

    ok that was the mistake!

    thx a lot

    ps: just don't forget to add the RETURN in the get for those who will take this code

    Edit: Ok it's fixed ;)



  • Misunderstanding about Binding