Russ Suter
asked on
How do I pass a xaml element as a property?
I'm still learning the mechanics of this whole WPF thing. I'm creating a user control. One of the things I want my control to be able to do is respond to click events of a control on the parent window. To do this, I have created a property called "Activator" like this:
public DependencyObject Activator { get; set; }
public static readonly DependencyProperty ActivatorProperty = DependencyProperty.Register("Activator", typeof(DependencyObject), typeof(NavView));
I then markup my Xaml like this: <Button Name="buttonShowHideMyControl" Grid.Column="1" VerticalAlignment="Top" HorizontalAlignment="Right" Style="{DynamicResource HeaderButton}" Grid.ColumnSpan="2" Margin="0,4,9,0">
<fa:FontAwesome Grid.Column="2" Icon="Bars" VerticalAlignment="Center" HorizontalAlignment="Left" Foreground="White" FontSize="24" Margin="10,4,0,4"/>
</Button>
<local:TestUserControl x:Name="testUC" Grid.Column="1" HorizontalAlignment="Right" Visibility="Hidden" Opacity="0" Activator="{Binding Property, ElementName=buttonShowHideMyControl}">
</local:TestUserControl>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER