0

I have a problem with my behavior using Microsoft Expression Blend. I don't know how to get the OnAttached event in Expression Blend or Visual Studio. It doesn't fire. Here's an example:

public class MyBehavior : Behavior<Path>
{
    public PathNavigation()
    {

    }

    protected override void OnAttached()
    {
        // Only firing in runtime
        base.OnAttached();
        AssociatedObject.Loaded += AssociatedObject_Loaded;
    }

    private void AssociatedObject_Loaded(object sender, System.Windows.RoutedEventArgs e)
    {
        // Only firing in runtime
    }
}

Is there a possibility to get that events while designing in Blend? Thanks in advance. Chris

chris6523
  • 530
  • 2
  • 8
  • 18

1 Answers1

1

Is it possible that at design time, AssociatedObject.IsLoaded == true? You could check that before attaching your event handler, and call a common OnLoaded method.

Abe Heidebrecht
  • 30,090
  • 7
  • 62
  • 66
  • I don't know, but even if it is true... Why can't I get the OnAttached-event? – chris6523 Jul 08 '13 at 12:43
  • 1
    Sorry, I had a reading comprehension problem obviously. Apparently behaviors are not attached during design time. So, that method won't get called. This question has a discussion about it: http://stackoverflow.com/questions/10154023/silverlight-blend-behaviors-do-not-get-attached-at-design-time – Abe Heidebrecht Jul 08 '13 at 13:29