in Education by
I'm trying to get some WPF concepts down, so I've put together a simple example of what I'm trying to do. I would like to set a custom property of a user control, and have it be used by an element within the control. I've been researching and experimenting, but I'm not fully understanding everything here. Any help would be appreciated. The user control for this example is a simple square with a circle inside of it: The VB Code Behind it: Partial Public Class CircleInSquare Private _CircleColor As Color Public Property CircleColor() As Color Get Return _CircleColor End Get Set(ByVal value As Color) _CircleColor = value End Set End Property End Class When I use this user control, how can I apply a CircleColor to the control, and have it be shown as the Ellipse's fill color? Even better... can I give it a default color that shows up in the VS2008 Designer? So... if I place one of these into my window XAML like this: I would like the circle to display as Blue (or any other color I choose for that instance) JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Sorry to repost, but After re-reading you post, I think that you might be better off with templating. I've attached some samples in VB Window.xaml CircleInSquare.xaml.vb Partial Public Class CircleInSquare Public Property CircleColor() As Brush Get Return GetValue(CircleColorProperty) End Get Set(ByVal value As Brush) SetValue(CircleColorProperty, value) End Set End Property Public Shared ReadOnly CircleColorProperty As DependencyProperty = _ DependencyProperty.Register("CircleColor", _ GetType(Brush), GetType(CircleInSquare), _ New FrameworkPropertyMetadata(Brushes.Black)) Public Property SquareColor() As Brush Get Return GetValue(SquareColorProperty) End Get Set(ByVal value As Brush) SetValue(SquareColorProperty, value) End Set End Property Public Shared ReadOnly SquareColorProperty As DependencyProperty = _ DependencyProperty.Register("SquareColor", _ GetType(Brush), GetType(CircleInSquare), _ New FrameworkPropertyMetadata(Brushes.Gray)) End Class CircleInSquare.xaml

Related questions

0 votes
    I'm trying to get some WPF concepts down, so I've put together a simple example of what I'm ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 5, 2022 in Education by JackTerrance
0 votes
    What is the property to access the first child of a node? (a) timestamp.Child1 (b) timestamp. ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 23, 2021 in Education by JackTerrance
0 votes
    What is the property to access the first child of a node? (a) timestamp.Child1 (b) timestamp. ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 21, 2021 in Education by JackTerrance
0 votes
    Part of the series of controls I am working on obviously involves me lumping some of them together in to ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 12, 2022 in Education by JackTerrance
0 votes
    Which property lays the element according to the normal flow? (a) relative (b) absolute (c) fixed ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 23, 2021 in Education by JackTerrance
0 votes
    Which is the element that has a src property to initiate HTTP GET request? (a) img (b) iframe (c ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 23, 2021 in Education by JackTerrance
0 votes
    I'm having an annoying problem registering a javascript event from inside a user control within a formview ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 13, 2022 in Education by JackTerrance
0 votes
    Is it possible to use an attribute of a child to group a query? Post.find(:all, :include => [ ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 17, 2022 in Education by JackTerrance
0 votes
    (a) “Gender of child is determined by the male partner of couple.” Draw a diagram explaining the above statement. Select the correct answer from above options...
asked Nov 9, 2021 in Education by JackTerrance
0 votes
    We can pass data from the parent component to the child component by using - 1. Input 2. @Input() 3. Output 4. @Output()...
asked Jun 29, 2021 in Technology by JackTerrance
0 votes
    which field is property is used to specifythe display layout of the field Select the correct answer from above options...
asked Dec 25, 2021 in Education by JackTerrance
0 votes
    An Input ……………….. is used to enter data in a performatted manner. a. rule b. mask c. property Select the correct answer from above options...
asked Dec 14, 2021 in Education by JackTerrance
...