English 中文(简体)
为什么在试图在用户委员会中启用一个文本箱时,我会错过了MainWindow。
原标题:Why do I get an error in the MainWindow when trying to initialize a textbox in a UserControl

我创建了一个<条码>UserControl,其中载有一个<条码>文本箱。 当我试图在<代码>UserControl的构造者中启动text Box时,加上一些案文,如此。

public FileSelector()
{
    InitializeComponent();
    TB_FolderPath.Text = @"c:	mpTest";
}

在MainWindow,我有了一个错误。 xaml

Cannot创设了一个“FileSelector”的例子。

当我搬走时

TB_FolderPath.Text = @"c:	mpTest";

我没有出现错误,但当然还有空洞的<条码>文本箱/代码>。

Previously when I had the parts of the UserControl integrated in the MainWindow, there was also no problem.

我试图利用复制这一问题的<代码>MainWindow/code>,制作一个更简单的版本。

So, my questions.

  • 问题的原因是什么?

  • 我如何系统地解答/分析像这样一个问题? 我在建筑后只拿到这个错误,没有解释。

  • • 我如何在上启动控制。 一般而言,<代码>UserControl 是否也有可能成为开始控制的适当场所? (这是完全可能的吗?)

最佳回答

在计生基金,与温森林不同,在开始实行管制后,控制措施没有完全启动。 因此,未经初步处理/卸载的控制将产生错误。

你们需要写手写,以掌握控制权的Loaded事件。

http://msdn.microsoft.com/en-us/library/ms754221.aspx”rel=“nofollow” 反对终身活动

Get some more detailed info here.


Example (partially taken from OP s code):

public FileSelector()
{
    InitializeComponent();
    TB_FolderPath.Loaded += delegate { TB_FolderPath.Text = @"c:	mpTest"; }
}
问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签