如果事件被路由,则在UserControl中显示按钮否则隐藏 [英] Show Button inside UserControl if Event is Routed else Hide

查看:61
本文介绍了如果事件被路由,则在UserControl中显示按钮否则隐藏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我正在为我的项目制作ToolBar菜单UserControl。 ToolBar将根据其经历的每种情况具有 n 数量的按钮。因此,例如在某些窗口工具栏中将有新的,编辑,删除按钮,但在其他窗口工具栏中可能有上传,下载和打印。这是一个简单的例子,它比这更复杂。



这是我到目前为止:

在UserControl(ToolBar) )

Hi,

I am making a ToolBar menu UserControl for my project. The ToolBar will have n quantities of buttons based on each situation it undergoes. So for example in certain windows toolbar will have new, edit, delete buttons, but in other it might have upload, download, and print. This is a simple example, it gets more complicated than that.

Here is what i have so far:
In the UserControl (ToolBar)

'NEW Button
Public Event btnNew_Click As btnNew_ClickedEventHandler
Public Delegate Sub btnNew_ClickedEventHandler(sender As Object)
Private Sub btnNew_MouseUp(sender As Object, e As MouseButtonEventArgs)
    RaiseEvent btnNew_Click(Me)
End Sub





此代码将通过xaml中的窗口显示此事件



This code will make this event visible from the Window in xaml

<toolbar btnNew_Click="Code_for_New_Record"/>





到目前为止一切顺利(一切正常)。但我想检查我的事件是否从MainWindow附加,如果不是,则隐藏它。



例如,如果我有按钮进行更新,删除,打印等等。而MainWindow的程序员只编写了New Button,只显示了新的Button。



问题:

如何判断事件是附加还是被叫?我想要一些代码说



如果myEvent IsNot附上那么

button.visibility =折叠

结束如果



感谢您的所有帮助!



So far so good (everything works). But I want to check if my Event is Attached from the MainWindow and if it is not, to hide it.

So for example, if i had buttons for update, delete, print, etc. And the programer for the MainWindow only coded the New Button, only the new Button should show.

Question:
How can I tell if the Event is attached or called? I would like to have some code that says

IF myEvent IsNot attached then
button.visibility = collapsed
end if

Thanks for all your help in advance!

推荐答案

希望这link [ ^ ]会帮助你


这篇关于如果事件被路由,则在UserControl中显示按钮否则隐藏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆