#UserControlのぷろぱてぃ UserControlにプロパティ作って、UserControlからもそのプロパティを参照したいときに何作る?というはなし
##元のコード
<UserControl
x:Class="App1.MyUserControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
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="Root">
<TextBlock />
</UserControl>
using System;
using System.Reactive.Linq;
using System.Threading;
using Windows.ApplicationModel;
using Windows.UI.Xaml.Controls;
namespace App1
{
public sealed partial class MyUserControl : UserControl
{
public MyUserControl()
{
this.InitializeComponent();
}
}
}
<TextBlock Text="{Binding Hoge,ElementName=Root}"/>
public string Hoge { get; set; }
<TextBlock Text="{Binding Hoge,ElementName=Root}"/>
public string Hoge
{
get { return (string)GetValue(HogeProperty); }
set { SetValue(HogeProperty, value); }
}
public static readonly DependencyProperty HogeProperty =
DependencyProperty.Register("Hoge", typeof(string), typeof(MyUserControl), new PropertyMetadata(null));