Skip to content

Instantly share code, notes, and snippets.

@euyuil
Last active January 3, 2016 10:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save euyuil/8451152 to your computer and use it in GitHub Desktop.
Save euyuil/8451152 to your computer and use it in GitHub Desktop.
WPF: in custom UserControl, expose its children's DependencyProperties.
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:my="clr-namespace:MyProject"
x:Class="MyProject.MyUserControl"
mc:Ignorable="d" d:DesignHeight="100" d:DesignWidth="640"
>
<Grid>
<!--
MyChildControl could be either a custom control or some built-in control.
It has a read-write DependencyProperty named MyReadWriteProperty,
and a readonly DependencyProperty named MyReadonlyProperty.
Both of them can be accessed from property wrappers named MyReadWrite and MyReadonly.
-->
<my:MyChildControl x:Name="MyChild" />
</Grid>
</UserControl>
public partial class MyUserControl : UserControl
{
public MyUserControl()
{
InitializeComponent();
}
public string MyChildReadonly
{
get { return MyChild.MyReadonly; }
}
public string MyChildReadWrite
{
get { return MyChild.MyReadWrite; }
set { MyChild.MyReadWrite = value; }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment