私の Silverlight 4 アプリでは、アプリケーションによって消費されるシンプルな UserControl を作成しようとしています。簡単にするために、「ヘッダー」と、任意の種類のコントロールを配置するプレースホルダーが必要です。
<User Control ...>
<Grid x:Name="LayoutRoot">
<TextBlock x:Name="TextBlockHeader" Text="{Binding Title}" />
<ContentPresenter x:Name="ContentPresenterObject" />
</Grid>
</UserControl>
コード ビハインドでは、TextBlock のテキストのプロパティを作成しました。
public string Title
{
get { return (string)GetValue(TitleProperty); }
set { SetValue(TitleProperty, value); }
}
public static readonly DependencyProperty TitleProperty = DependencyProperty.Register("Title", typeof(string), typeof(MyAccordion), null);
このようにして、アプリケーションで Control を使用するときに Title プロパティを設定できます。
<local:MyAccordion Title="Test"/>
しかし、テキストブロック Text="{Binding Title}" でのバインディングでは、テキスト「Test」がテキストブロックのテキストとして表示されないようです。
私の質問は次のとおりです。プロパティ タイトルをテキスト ボックスのテキストとして表示するにはどうすればよいですか?
前もってありがとう、
フランク