-
January 25th, 2011, 05:43 AM
#1
WPF Object binding
As I know, binding is a technique applied only for properties of an object. Is there any way for us to bind the whole object?
If you don't figure out the question, let's see the case below:
I want to create a WPF user control exposing a property called InnerCaption (TextBlock variable)
XAML code
<UserControl x:Class="myControl.UserControl1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid>
<TextBlock Name="_innerCaption" > Hello</TextBlock>
</Grid>
</UserControl>
CS code behind
namespace myControl
{
/// <summary>
/// Interaction logic for UserControl1.xaml
/// </summary>
public partial class UserControl1 : UserControl
{
public UserControl1()
{
InitializeComponent();
}
public TextBlock InnerCaption
{
get { return (TextBlock)this.GetValue(InnerCaptionProperty); }
set { this.SetValue(InnerCaptionProperty, value); }
}
public static readonly DependencyProperty InnerCaptionProperty = DependencyProperty.Register(
"InnerCaption", typeof(TextBlock), typeof(UserControl1),new PropertyMetadata(false));
}
}
I want users to be able to customize the InnerCaption at design time such as: modifying its color, its font style ... But I don't know how. Show me a way pls!
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|