Help! a confused trouble about my cumstom activity.

hi,

I am coding a custom activity, which has a DependencyProperty named myProperty1. and this myProperty1 is a subclass of DependencyObject in the same assembly. My custom activity works well with Designer. However, while i run the assembly compiled from the XAML file generated by Designer, it allways fails. Then i disamble this assembly by Reflector, it confused me that Compiler DOESN'T generate a field matched with myProperty1. Why? Is it a BUG?

Some codes as following:

public class myCustomActivity: Activity
{
...
public myClass1 myProperty1
{
get{...}
set{...}
}
...
}

pubic class myClass1: DependencyObject
{
public string Name
{
get{...}
set{...}
}
}

//generated some codes by compiler as following
//Note: myProperty1 not GENERATED!
private void InitializeComponent()
{
base.CanModifyActivities = true;
this.myCustomActivity1 = new myCustomActivity();
....
base.Activities.Add(this.myCustomActivity1);
....
base.Name = "Workflow1";
base.CanModifyActivities = false;
}

Thanks in advance!

[1177 byte] By [funwolf] at [2007-12-21]
# 1

I think what you really want is to register your property as a dependency property. Then your class does not have to derive from anything specific. Like so:

public class myCustomActivity: Activity
{

public static DependencyProperty myProperty1Property = System.Workflow.ComponentModel.DependencyProperty.Register("myProperty1", typeof(myClass1), typeof(Workflow1));

[Description("Your description here")]
[Category("Your category here")]
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public myClass1 myProperty1
{
get
{
return ((myClass1)(base.GetValue(Workflow1.myProperty1Property)));
}
set
{
base.SetValue(Workflow1.myProperty1Property, value);
}
}...
}

pubic class myClass1
{
public string Name
{
get{...}
set{...}
}
}

Matt

MattMilner-Pluralsight at 2007-9-10 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...

Software Development for Windows Vista

Site Classified