基本的にボタンであるUserControlを作成しました。これは、画像とその上にラベルを持っていると私はそうのようなイメージの源とラベルのテキストを設定するには、2つのプロパティを作成しました:しかしC#WPFカスタムコントロールは、デザイン時にXAMLプロパティに応答しませんか?
public ImageSource Icon
{
get { return (ImageSource)this.GetValue(IconProperty); }
set { this.SetValue(IconProperty, value); icon.Source = value; }
}
public static readonly DependencyProperty IconProperty = DependencyProperty.Register("Icon", typeof(ImageSource), typeof(NavigationButton));
public string Text
{
get { return (string)this.GetValue(TextProperty); }
set { this.SetValue(TextProperty, value); label.Content = value; }
}
public static readonly DependencyProperty TextProperty = DependencyProperty.Register("Text", typeof(string), typeof(NavigationButton));
、私は私のページにコントロールを追加した、コントロールを私はXAMLで設定したプロパティに応答しません。 <controls:MusicButton Icon="/SuCo;component/Resources/settings.png/>
は何もしません。
私は間違っていますか?
私が追加「dependencyObject.SetValue(Image.SourceProperty、e.NewValueは);」 OnIconChangedのvoidに変換し、設計や実行時には何もしないように見えます。 XAMLのデフォルトのSource値をクリアしても、それを修正することはできません。それ以上のアドバイスはありますか? :P –
私の編集は役に立ちますか?そうでない場合は、すべてのコードとXAMLを投稿できますか? –