Create UserControl DependencyProperty of which value can be chosen in dropdown list (as combo box)

Posted by Viet on Stack Overflow See other posts from Stack Overflow or by Viet
Published on 2010-03-18T10:29:15Z Indexed on 2010/03/18 10:31 UTC
Read the original article Hit count: 432

Filed under:
|
|
|

Hello everybody,

I'm a starter at WPF, now i would like to make a WPF userControl library which include a Rating bar userControl. All the steps of creating the rating Bar has been done, however i would like to add a property RatingValue:

public static readonly DependencyProperty RatingValueProperty =
            DependencyProperty.Register("RatingValue", typeof(int), typeof(RatingControl),
            new FrameworkPropertyMetadata(0, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, new PropertyChangedCallback(RatingValueChanged)));

public int RatingValue
        {
            get { return (int)GetValue(RatingValueProperty); }
            set
            {               
                SetValue(RatingValueProperty, value);                
            }
        }

private static void RatingValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
         //... change the rating value
        }

that the user of my UserControl can modify by a value from 0 to 5 that are shown in a dropdown list (combo box) in the Properties windows (as some exist properties of Usercontrols like Visibility, windows style, background ...)

How can i do? Thank you very much in advance,

Viet

© Stack Overflow or respective owner

Related posts about wpf

Related posts about dependency