ヘッダープロパティを使用して、カスタムの「PageHeaderControl」UserControlを作成しています。
public partial class PageHeaderControl: UserControl
{
public static readonly DependencyProperty HeaderProperty =
DependencyProperty.Register("Header",
typeof(string), typeof(PageHeaderControl),
new PropertyMetadata(""));
public string Header
{
get { return GetValue(HeaderProperty) as string; }
set { SetValue(HeaderProperty, value); }
}
}
そのコントロールのXAMLには、次のものがあります。
<sdk:Label Content="{Binding Header,Mode=TwoWay}" />
ここで問題があります。コントロールを作成するとき、それをバインドすると、これを行うためにのみ機能します。
<my:PageHeaderControl Header="This is my page header" />
そして、これを行うことはできません。ここでPageHeader
、ヘッダー値を保持しているViewModelのプロパティは次のとおりです。
<my:PageHeaderControl Header="{Binding PageHeader,Mode=TwoWay}" />
私のプロパティが台無しになっているのではないかと思いましたが、これも機能します。
<TextBlock Text="{Binding PageHeader,Mode=TwoWay}" />
問題が何であるかについてのアイデア!
本当にありがとう!!!
編集:
私のViewModelでは、PageHeaderは次のとおりです。
private string _pageHeader = "This is my page header";
public string PageHeader
{
get
{
return _pageHeader;
}
set
{
_pageHeader = value;
RaisePropertyChanged("PageHeader");
}
}
編集2:
プロパティの「get」内にブレークポイントを設定PageHeader
すると、TextBlockを追加しない限り、ブレークポイントはまったくヒットしません...