[英]Fire Parent event based upon child control event in WPF
I have a user control that contains button as follows 我有一个包含按钮的用户控件,如下所示
<UserControl x:Class="MyNamespace.myuseercontrol>
<Button Name="uxRemove" Grid.Row="2" Grid.Column="5" VerticalAlignment="Center"
HorizontalAlignment="Right" Width="70" Content="Remove"
Click="uxRemove_Click"/>
</UserControl>
the main window is as follows : 主窗口如下 :
<Window>
<stackpanel>
<local:MyUserControl x:Name="uxPanel1" />
</stackpanel>
</Window>
Requirements: 要求:
The MDI-style solution may be a bit overcomplicated for what you are doing. 对于您正在做的事情,MDI风格的解决方案可能有点过于复杂。
There is an example of raising events from child controls to a parent window here . 这里有一个从子控件向父窗口引发事件的示例 。
This is the basic gist: 这是基本要点:
This is a much simpler solution for you than implementing an MDI style WPF application. 与实现MDI样式的WPF应用程序相比,这是一个更简单的解决方案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.