visual studio - How do I initialize a XAML UserControl with fake data design-time when working with the control itself? -
I have a basic WinRT XAML UserControl, as implemented with the same dependency property below. User control is apparently only design time created when used in any other page or user stront. The text is not rendered "Hello World", when I work with the user in the designer with the control. How can I make user control with the user in this case as a designer?
XAML:
& lt; UserControl x: class = "GTWin8.Ui.SimpleBinding" Xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns: x = "http://schemas.microsoft.com/winfx/ 2006 / xaml "xmlns: local =" using: GTWin8 .UI "xmlns: D =" http://schemas.microsoft.com/expression/blend/2008 "xmlns: mc =" http: //schemas.openxmlformats .org / markup-compatibility / 2006 "MC: Ignorable =" D "d: DesignHeight =" 300 "d: DesignWidth =" 400 "x: name =" This Control "& gt; & Lt; Grid Background = "Black" & gt; & Lt; TextBlock Text = "{Binding Path = Message, ElementName = This Control}" Horizontal Alignment = "Left" margin = "10,10,0,0" TextWapping = "Wrap" vertical alignment = "top" height = "280" width = "380" /> & Lt; / Grid & gt; & Lt; / UserControl & gt; Public sealed partial class scrubbing: user control (public reliance dependency) message credentials = dependency. Registration ("message", typef (string) code-behind: , typef (serlinking), new property matadata (empty)); Receive public string message {return {string} gateway (messageproperty); } Set {set value (messageproperty, value); }} Public plain binding () {this.InitializeComponent (); Message = "Hello World"; }}
OK, a simple method is a declaratory call.
& lt; UserControl & gt; & Lt; D: Page.DataContext & gt; & Lt; Sample: Fake viewmodel / & gt; & Lt; / D: Page.DataContext & gt; & Lt; Grid & gt; & Lt ;! - Your bind / content - & gt; & Lt; / Grid & gt; & Lt; / UserControl & gt; I use it in all my projects because it distributes design time data without interfering with my runtime experience. More:
Comments
Post a Comment