Witam wszystkich serdecznie!
Mam Kontrolkę użytkownika, a w niej 3 inne (te same) kontrolki użytkownika. Chcę stworzyć grupę DependencyProperty. Stworzyłem klasę dziedziczącą po DependencyObject:
public class ImageButtonDependencyProperty : DependencyObject
{
public ImageButtonDependencyProperty(eImage ImageType, string Text)
{
this.ImageType = ImageType;
this.Text = Text;
}
public eImage ImageType
{
get { return (eImage)GetValue(ImageTypeProperty); }
set { SetValue(ImageTypeProperty, value); }
}
// Using a DependencyProperty as the backing store for ImageType. This enables animation, styling, binding, etc...
public static readonly DependencyProperty ImageTypeProperty =
DependencyProperty.Register("ImageType", typeof(eImage), typeof(ImageButtonDependencyProperty), new PropertyMetadata(eImage.Nothing));
public string Text
{
get { return (string)GetValue(TextProperty); }
set { SetValue(TextProperty, value); }
}
// Using a DependencyProperty as the backing store for Text. This enables animation, styling, binding, etc...
public static readonly DependencyProperty TextProperty =
DependencyProperty.Register("Text", typeof(string), typeof(ImageButtonDependencyProperty), new PropertyMetadata(""));
public Brush Foreground
{
get { return (Brush)GetValue(ForegroundProperty); }
set { SetValue(ForegroundProperty, value); }
}
// Using a DependencyProperty as the backing store for Foreground. This enables animation, styling, binding, etc...
public static readonly DependencyProperty ForegroundProperty =
DependencyProperty.Register("Foreground", typeof(Brush), typeof(ImageButtonDependencyProperty), new PropertyMetadata(Brushes.Black));
}
utworzyłem DependencyProperty wewnątrz kontrolki:
public ImageButtonDependencyProperty ButtonStyle
{
get { return (ImageButtonDependencyProperty)GetValue(ButtonStyleProperty); }
set { SetValue(ButtonStyleProperty, value); }
}
public static readonly DependencyProperty ButtonStyleProperty =
DependencyProperty.Register
(
"ButtonStyle",
typeof(ImageButtonDependencyProperty),
typeof(ImageButton),
new PropertyMetadata(new ImageButtonDependencyProperty(eImage.Nothing, "")
));
Nie mogę jednak bindować do DependencyProperty wewnątrz DependencyProperty:
[Wyszukiwanie Property]
====================================
[Wybranie property]
====================================
Chciałbym uzyskać efekt taki jak tu:
====================================
macie jakieś porady dla nowicjusza? Staram się jak mogę naprawdę :)
- screenshot-20180802003725.png (9 KB) - ściągnięć: 142
- screenshot-20180802003612.png (2 KB) - ściągnięć: 80
- screenshot-20180802003534.png (10 KB) - ściągnięć: 99
- screenshot-20180802003602.png (2 KB) - ściągnięć: 93