Last active
January 3, 2016 10:39
-
-
Save euyuil/8451152 to your computer and use it in GitHub Desktop.
WPF: in custom UserControl, expose its children's DependencyProperties.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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