WPF中lable显示问题
在WPF(VS2008)中加入如下代码(VS2005没有试过):<label content=”this is a label” name=”lbl1” />
<ListBox >
<wfi:WinddowsFormsHost>
<wf:dateTimePicker>
</wfi:WindowsFormsHost>
</ListBox>
在运行后会发现lable上的内容不见了,同时出现这种情况的还有Button,但是Button点一下后,上面的内容会出来,就是初始的时候不显示。
同时我发现如果去了<ListBox>,显示就正常了,不知这是什么原因请高手给解一下!!
--------------------编程问答-------------------- <wfi:WinddowsFormsHost>
<wf:dateTimePicker>
</wfi:WindowsFormsHost>
????? --------------------编程问答-------------------- 以下是完整的代码:
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:wfi="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration"
xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
Title="sample5" Height="300" Width="300">
<Grid>
<Label Margin="32,24,48,0" Content=" this is a label" Name="lbll" Height="28" VerticalAlignment="Top" />
<ListBox Margin="32,83,30,0" Height="29" VerticalAlignment="Top">
<wfi:WindowsFormsHost>
<wf:DateTimePicker />
</wfi:WindowsFormsHost>
</ListBox>
</Grid>
</Window>
--------------------编程问答-------------------- 不明白你说的Button是哪个Button. 而且并没有出现你说的情况。要不你试一下这一段,测试好的。
<Window x:Class="WinformIntegration.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:wfi="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration"
xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
Title= "sample5" Height= "300" Width= "300">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Label Grid.Row="0" Content= "this is a label" Name= "lbll" VerticalAlignment= "Top" />
<wfi:WindowsFormsHost Grid.Row="1">
<wf:DateTimePicker />
</wfi:WindowsFormsHost> <Button Grid.Row="2" Content="什么Button?" />
</Grid>
</Window>
--------------------编程问答-------------------- 受不了。
正如楼上所说,哪里来的BUTTON。
而且你把WindowsFormsHost放在ListBox中干什么? --------------------编程问答-------------------- 建议加一个 StackPanel 默认是上下的布局 然后想把显示的控件加到StackPanel 里 --------------------编程问答-------------------- lz要干嘛? --------------------编程问答-------------------- 好像没那么简单,呵呵.
补充:.NET技术 , 组件/控件开发