I have a basic WinRT XAML UserControl with a single dependency property as implemented below. The user control is apparently only constructed design-time when used in another Page or UserControl. The text "Hello world" is not rendered when I work in the designer with the user control itself. How can I make the designer initialize the user control with data also in this case?
XAML:
<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="ThisControl">
<Grid Background="Black">
<TextBlock Text="{Binding Path=Message, ElementName=ThisControl}"
HorizontalAlignment="Left" Margin="10,10,0,0"
TextWrapping="Wrap" VerticalAlignment="Top" Height="280" Width="380"/>
</Grid>
</UserControl>
Code-behind:
public sealed partial class SimpleBinding : UserControl
{
public static DependencyProperty MessageProperty = DependencyProperty.Register(
"Message", typeof(String), typeof(SimpleBinding), new PropertyMetadata(null));
public String Message
{
get { return (String)GetValue(MessageProperty); }
set { SetValue(MessageProperty, value); }
}
public SimpleBinding()
{
this.InitializeComponent();
Message = "Hello world";
}
}