Adding Properties to Custom WPF Control?

Up vote 0 down vote favorite share g+ share fb share tw.

I just started WPF this morning so this is (hopefully) an easy question to solve. I've started with creating a button that has a gradient background. I want to declare the gradient start and end colors in the property of the control and then apply them in the template.

I'm having trouble getting the code to compile though. The exception I'm getting is that the xaml is telling me the property is not accessible but when I chang the visiblity modifier over to public it complains it can't find the static property... Here's my xaml so far: And here's the code for my custom control: public class GradientButton : Button { static DependencyProperty GradientStartProperty; static DependencyProperty GradientEndProperty; static GradientButton() { GradientStartProperty = DependencyProperty. Register("GradientStart", typeof(Color), typeof(GradientButton)); GradientEndProperty = DependencyProperty.

Register("GradientEnd", typeof(Color), typeof(GradientButton)); } public Color GradientStart { get { return (Color)base. GetValue(GradientStartProperty); } set { base. SetValue(GradientStartProperty, value); } } public Color GradientEnd { get { return (Color)base.

GetValue(GradientEndProperty); } set { base. SetValue(GradientEndProperty, value); } } } EDIT: Here's the design-time exception I'm getting Cannot reference the static member 'GradientStartProperty' on the type 'GradientButton' as it is not accessible. C# .net wpf xaml link|improve this question edited Jul 6 '10 at 18:25 asked Jul 6 '10 at 17:43Sonny Boy2,0271830 92% accept rate.

I figured it out... This: static DependencyProperty GradientStartProperty; static DependencyProperty GradientEndProperty; Needed to be changed to this: public static DependencyProperty GradientStartProperty; public static DependencyProperty GradientEndProperty.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions