按MSDN里的文章,能够实现其例子,即在Windows Presentation Foundation 中承载 Windows 窗体控件.可是在我的工程里, Windows 窗体控件不可见.只有位置轮廓.怎么解决啊?同样的代码,在我的工程里运行, Windows 窗体控件不可见. System.Windows.Forms.Integration.WindowsFormsHost host =
new System.Windows.Forms.Integration.WindowsFormsHost(); // Create the MaskedTextBox control.
MaskedTextBox mtbDate = new MaskedTextBox("00/00/0000"); // Assign the MaskedTextBox control as the host control's child.
host.Child = mtbDate; // Add the interop host control to the Grid
// control's collection of child controls.
this.grid1.Children.Add(host);
new System.Windows.Forms.Integration.WindowsFormsHost(); // Create the MaskedTextBox control.
MaskedTextBox mtbDate = new MaskedTextBox("00/00/0000"); // Assign the MaskedTextBox control as the host control's child.
host.Child = mtbDate; // Add the interop host control to the Grid
// control's collection of child controls.
this.grid1.Children.Add(host);
解决方案 »
- C#算术错误
- 用PrintPreviewDialog 怎样显示对话框中要预览的文档?
- C#中怎么把Combox中选中的数转换为整型数值?
- 在mdi模式中,子窗体已经打开了,请问,如何使用菜单来访问子窗体中的控件或者方法
- 有什么工具可以查看IE请求信息的?
- 如何向一个txt文件写入n(为变量)个相同的字符或字符串?
- 关于MSMQ的
- 实现关键字搜索网站里的文章 好像是模糊查找吧?
- 怎样在C#中打开一个access数据库(*.mdb),获得其中所有的表格名称。
- 出现在application.run()的System.NullReferenceException异常
- Dev Gridcontrol 的自增列
- c# 微积分的计算
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="testWPF.Window1"
x:Name="Window"
Title="Window1"
AllowsTransparency="True" 原因是我把主窗体的AllowsTransparency="True", 这样设置了,只要去掉这个设置, 窗体控件就能正常显示,可是我为了实现主窗口的特效, 必须保留这个设置, 这样该如何解决呢?
用这个方法替代下<Grid Margin="20" HorizontalAlignment="Left" VerticalAlignment="Top">
<Border BorderBrush="LightBlue" BorderThickness="1" SnapsToDevicePixels="True"/>
<StackPanel Margin="5" Orientation="Horizontal" VerticalAlignment="Top">
<TextBox Width="40" MaxLength="2" BorderThickness="0"/>
<TextBlock Text="/" Padding="2,0"/>
<TextBox Width="40" MaxLength="2" BorderThickness="0"/>
<TextBlock Text="/" Padding="2,0"/>
<TextBox Width="80" MaxLength="4" BorderThickness="0"/>
</StackPanel>
</Grid>