アタッチされたプロパティがあり、Windows8ではアタッチプロパティにバインドできないようです。Silverlight/WPFではこの方法を自由に使用できますが、なぜ許可されないのかわかりません。MSDNフォーラムの投稿によると、Windows 8リリースで修正されました。現在リリースされていますが、機能しません。「値が期待範囲内にない」と表示されます。
public static class CountHelper
{
public static readonly DependencyProperty TitleProperty =
DependencyProperty.RegisterAttached("Title", typeof (string), typeof (CountHelper), new PropertyMetadata(default(string)));
public static void SetTitle(UIElement element, string value)
{
element.SetValue(TitleProperty, value);
}
public static string GetTitle(UIElement element)
{
return (string) element.GetValue(TitleProperty);
}
}
XAMLファイル
<TextBlock local:CountHelper.Title="Hello" Text="{Binding Path=(local:CountHelper.Title)}"/>