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:
<UserControl x:Class="CircleInSquare"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Width="100" Height="100" >
<Grid Background="#000000">
<Ellipse Name="Circle"
Margin="10"
Fill="?????????"
>
</Ellipse>
</Grid>
</UserControl>
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:
<app:CircleInSquare CircleColor="Blue" />
I would like the circle to display as Blue (or any other color I choose for that instance)