locked
Design time data binding for XAML in VS 11?

    Question

  • Will there be any support for design-time data binding of controls in VS 11? There doesn't appear to be (not that I've been able to find, anyway). Developing data-bound custom controls gets a little tedious, because I need to run my application in order to render the control - when you're tweaking fonts and margins, this gets old very quickly after a couple of iterations.  

    Alternatively, are there any conditional compilation sorts of annotations possible in XAML? Such that the XAML designer could use, for example,  Text="Concrete Value" for the text of a control that would use Text="{Binding Path=path.to.my.value}" at run time. 

    This is one of the biggest points of friction for developing a data bound Metro control for me - getting the rendering tweaked without a lot of frustrating compile/run cycles. 

    Monday, October 3, 2011 11:44 PM

Answers

  • Aaaaah, <UserControl.DataContext>...</UserControl.DataContext>, it's all clear now :)

    (obviously, I'm new to XAML, and I've been trying to stick to the WinRT documentation as much as possible, since the WPF docs are full of stuff that doesn't exist in WinRT...)

    • Marked as answer by Adam Alpern Thursday, October 6, 2011 9:01 PM
    Thursday, October 6, 2011 9:01 PM

All replies

  • Hi Adam.  You should look at Unni's presentations from BUILD to see the existing and some known limitations. 

    There also is no conditional compile statements in XAML at this time.


    Tim Heuer | Program Manager, XAML | http://timheuer.com/blog | @timheuer
    Tuesday, October 4, 2011 12:07 AM
  • Thanks! That was helpful. 

    It turns out that what I want is as simple as checking Windows.ApplicationModel.DesignMode.DesignModeEnabled in the constructor of my control, and this.DataContext to a dummy value if true. 

    UPDATE: Slight modification - that's 1/2 helpful; it binds a control when I instantiate it on another control, but doesn't help when I'm editing the user control itself. 
    • Edited by Adam Alpern Thursday, October 6, 2011 12:00 AM
    Wednesday, October 5, 2011 11:20 PM
  • Aaaaah, <UserControl.DataContext>...</UserControl.DataContext>, it's all clear now :)

    (obviously, I'm new to XAML, and I've been trying to stick to the WinRT documentation as much as possible, since the WPF docs are full of stuff that doesn't exist in WinRT...)

    • Marked as answer by Adam Alpern Thursday, October 6, 2011 9:01 PM
    Thursday, October 6, 2011 9:01 PM