2016-05-04 5 views
0

TextBoxから継承し、新しいDependencyProperty "TableName"を追加したWPF CustomControlを作成しました。コントロールがバインドされているDataTableの名前を設定できます。 コントロールは実行時に生成され、プロパティTableName p.e. "table1"に設定します。 我々はあまりにもバインディングをシリアライズしたいので、その後、我々は、CodeProjectのからこの記事のようなXAMLファイルに(私たちのCustomControlのような)のコントロールが含まれているパネルをシリアライズ:残念ながらWPF CustomControlのプロパティがXamlWriterによってシリアル化されていません

XamlWriter-and-Bindings-Serialization

- 代わりのような性質のWidth - 新しいDependencyPropertyはシリアル化されていません。

XamlWriterにプロパティのシリアル化を強制する方法はありますか?

ありがとうございます!

これはCustomControlのプロパティの定義は、 "CustomTextBox" と呼ばれている:

public static readonly DependencyProperty TableNameProperty = DependencyProperty.Register("TableName", typeof(string), typeof(CustomTextBox)); 

public string TableName { get; set; } 

それはGeneric.xamlでスタイルです:

<Style TargetType="{x:Type local:CustomTextBox}" BasedOn="{StaticResource {x:Type TextBox}}"> 
</Style> 

答えて

0

あなたはCLRプロパティを提供してきたが、それはdoesnの何もしない。 DependencyPropertyにリンクする必要があります。

public string TableName 
{ 
    get { return (string)GetValue(TableNameProperty); } 
    set { SetValue(TableNameProperty, value); } 
} 
+0

ありがとうございます!それでおしまい。 :) –

関連する問題