3
如果我有一个用户控件如何在UserControl外部为控件分配事件处理程序?
<UserControl
x:Class="UserInterface.AControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid>
<Button
Content="Set"
Name="setButton" />
</Grid>
</UserControl>
如何使用此控件外部时分配的事件处理程序setButton
?
<UserControl
xmlns:my="clr-namespace:UserInterface"
x:Class="UserInterface.AnotherControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid>
<my:AControl />
</Grid>
</UserControl>
我可以使用类似的东西吗?
<my:AControl
setButton.Click="setButton_Click" />