Ask a questionAsk a question
 

Answer2008 add-in for the WPF designer

  • Sunday, April 20, 2008 9:13 PMjuffowup Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

     

    Greetings,

     

    I'm upgrading an add-in from VS 2005 to VS 2008.  Part of the add-in is to examine what control the user has selected in the designer.  For WinForms I do this by looking at the Active window, get a reference to IDesignerHost from the window's Object, then I attach to the IDesignerHost SelectionChanged event to see what has the focus.  This works fine in 2005 and 2008.  Now I'm presented with the WPF pickle.

    On a window containing the WPF/Xaml designer the window's Object is null.  With the Object being null I have no idea how I'm supposed to find out which control is selected.  How can I find out what control is selected in the WPF designer with my add-in?

     

    Thanks,

Answers

  • Tuesday, April 29, 2008 11:08 PMMark BoulterModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    We don’t support it unless you have a control on the page. If you have a control on the page you can use the metadata store to add attributes to any class you wants, including Control or FrameworkElement. If you do that it would appear for every control on the form

    mark

     

All Replies

  • Wednesday, April 23, 2008 8:34 PMMark BoulterModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    The WPF designer doesn't support this in VS 2008.

    Sorry.

    mark

  • Thursday, April 24, 2008 6:10 PMjuffowup Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

     

    I'm confused then.  The Properties window has all this information when the user selects a control.  What I really need is to just know what Control is selected in the designer.  If you're telling me I can't get that information directly is it possible for me to get that information from the Properties window itself?

     

    Thanks,

  • Thursday, April 24, 2008 8:44 PMMark BoulterModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    There isn't a way to get to that information from inside an addin - we don't expose it. The designer and the property browser and the document outline all live in a seperate app domain and we don't marshal a proxy back to the primary domain where the addin lives.

     

    mark

  • Thursday, April 24, 2008 10:00 PMjuffowup Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

     

    Do'h!  Well that pretty much shoots my project in the foot.   This seems like a pretty glaring omission for add-in developers.  Who do I have to bribe to get this functionality added to SP1 for VS2008?

  • Thursday, April 24, 2008 11:53 PMMark BoulterModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    It won't be in VS 2008 SP1, sorry. What was it you were trying to do?

    mark

     

  • Friday, April 25, 2008 5:58 PMjuffowup Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    With my current Add-in when I select a control in the WinForms Designer I get access to the control.  I can make changes to it, add new controls, or just pull info from it for documentation purposes.  I was hoping I could extend this functionality to work with the WPF designer.

     

    I guess in the end what I'm really looking for is a way to have my code interact with the objects as they sit on the WPF designer.  I'm open to any work around for this you might be able to suggest. 

     

    Is there a way I could add an option to the context menu the WPF designer displays when you right click on any it’s elements?  I've seen ways to do that for specific custom controls but not for the designer as a whole.

     

    I appreciate your help on this.

    Thanks,

  • Tuesday, April 29, 2008 11:08 PMMark BoulterModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    We don’t support it unless you have a control on the page. If you have a control on the page you can use the metadata store to add attributes to any class you wants, including Control or FrameworkElement. If you do that it would appear for every control on the form

    mark

     

  • Wednesday, April 30, 2008 11:02 PMjuffowup Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Sounds good.  I'll give that a shot. 
  • Monday, May 05, 2008 11:53 PMkhanson Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Mark,

     

    I just want to get a bit of clarification.  You are saying there is no way to get a Interface to the WPF Designer (Cider) in VS2008 in such a way that I could see selection changed events for individual shapes or wpf controls on the surface? 

     

    How is the IronPython source interacting with the Designer?  To be honest I didn't see any event notification logic related to the designer, but I do know that IronPython is using it.

     

    I am pretty discouraged that there appears no way to do extensibilty that works with XAML.

     

    Thanks,

     

    Ken

  • Wednesday, May 07, 2008 8:08 PMMark BoulterModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    There is no support for accessing the designer or its state from an addin. From within the designer - if you write a design time extension for a control - you can access the designer state.

     

    For VS 2008 our priority for extensibility was to enable the same level of support for writing control design times that the Windows Forms designer has so that 3rd parties could provide rich design time support for their controls.

     

    Iron Python integrates via VSIP but even at that level they don’t see selection change events from the designer - the selection synchronization you are seeing is driven from the designer rather than the reverse.

     

    If you want to automate creation of WPF UI you could write an addin that generated XAML and pushed it into the XAML file - for example Ken Spencer has written a databinding addin that does this

     

    mark