我需要建立多个按钮,但我不能显示任何按钮!这是我用IronPython2.7编写的WPF应用程序代码。。在
我试过两种不同的方法Grid.Children.Add(按钮)“如果没有这个,什么都不会显示。。在
XAML:
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:Forms="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
x:Name="NewWindow" Height="564.22" Width="993.2">
<Grid x:Name="grid" Margin="0,0,75.2,92.4">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Button Content="Create a Button from code" HorizontalAlignment="Left"
Margin="712,418,0,0" VerticalAlignment="Top" Width="167" Height="61"
Click="CreateButtons_Click"/>
</Grid>
</Window>
代码:
^{pr2}$显示错误:
expected UIElement, got Button
如果我跳过那个错误并删除行self.grid.Children.添加(self.myButton),它不会得到错误,但也不会显示任何按钮。在
如何通过python代码在那里显示我的按钮?(python和wpf的新成员)
我发现了问题所在!!(太容易了,我无法接受!)在
UIElement的错误是因为(我不知道有两种按钮,对不起!)我正在从导入按钮系统.Windows.Forms并且必须从导入正确的按钮System.Windows.控件
大家好天气!在
相关问题 更多 >
编程相关推荐