我在代码中创建了任意数量的用户控件。每个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 UserControlFor 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
发布评论