在usercontrol中的菜单项上使用AddHandler

编程入门 行业动态 更新时间:2024-10-28 00:16:01
本文介绍了在usercontrol中的菜单项上使用AddHandler的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在代码中创建了任意数量的用户控件。每个usercontrol都是一个RadCartesianChart,并有一个菜单项,用于扩展该用户控件的大小。为菜单项单击添加处理程序。我在让的处理程序正常工作时遇到了问题。

I create any number of user controls in code. Each usercontrol is a RadCartesianChart and has a menu item for expanding the size of that user control. A handler is added for the menu item click. I'm having problems getting the handler to work correctly.

" uc"被分配了新创建的用户控件。单击菜单项时,没有任何反应。类似的"缩放"代码用于在xaml中创建的用户控件。传入xaml usercontrol并增加高度和宽度。我希望这段代码也适用于代码创建的用户控件。

"uc" is assigned the newly created usercontrol. When the menu item is clicked, nothing happens. Similar "Zoom" code is used for usercontrols created in xaml. The xaml usercontrol is passed in and the height and width increased. I was hoping that this code would work for the code-created usercontrols, too.

我正在使用Telerik控件但我不喜欢我认为这是一个Telerik问题。

I'm using Telerik controls but I don't think this is a Telerik problem.

添加usercontrol的代码:

Code to add usercontrol:

Dim uc As UserControl

For i = 1 To intDesignerCount Dim designerUC() As UserControl = New UserControl((ii) - 1) {} designerUC(0) = New UserControl designerUC(0).Height = 325 designerUC(0).Width = 500 'create menu bar Dim menuBar As New RadMenu menuBar.Background = New SolidColorBrush(...)) Dim menuLabel As New RadMenuItem menuLabel.Header = menuLabelHeader menuBar.Items.Add(menuLabel) Dim itemMargin = menuBar.Margin itemMargin.Left = 200 Dim zoomItem As New RadMenuItem zoomItem.Header = "+" zoomItem.Margin = itemMargin menuBar.Items.Add(zoomItem) AddHandler zoomItem.Click, AddressOf btnZoomByDesigner_Click pnl.Children.Add(menuBar) '----------------------- 'create chart Dim chart As RadCartesianChart = New RadCartesianChart

处理程序代码:

Private Sub btnZoomByDesigner_Click() uc.Height = 800 uc.Height = 800 uc.Width = 800 End Sub

感谢您的帮助。

推荐答案

为什么不在XAML中创建UC?使用XAML并在XAML中创建处理程序。 Why are you not creating your UC in XAML? Use XAML and create the handler in XAML.

更多推荐

在usercontrol中的菜单项上使用AddHandler

本文发布于:2023-11-16 19:33:38,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1607171.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:单项   中的菜   usercontrol   AddHandler

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!