WPF错误添加用户控制
发生的错误,当我包含在这一行我自己的用户控件(拖动&下降):WPF错误添加用户控制
<my:ItemParte x:Name="UcItemParte" Panel.ZIndex="6" />
和错误说:“对象未设置为一个实例目的。”
我不知道为什么......有什么帮助?
UPDATE: 这是次新()
共享子新() ListViewFontSizeProperty = DependencyProperty.Register( “ListViewFontSize”,_ 的GetType(双),的GetType(ItemParte)) 结束子
Public Sub New()
Try
mModeloItem = Modelo_Item.Instance
mModeloParte = Modelo_Parte.Instance
mModeloParteLinea = Modelo_Parte_Linea.Instance
' Llamada necesaria para el Diseñador de Windows Forms.
InitializeComponent()
' Agregue cualquier inicialización después de la llamada a InitializeComponent().
If Not IsInDesignMode Then
mTextos = Textos.Instance
mConfig = Config.Instance
MainWin = My.Application.MainWindow
AddHandler MainWin.VentanaMensaje.ButtonAceptarExec, AddressOf VentanaMensaje_AceptarClickCallback
AddHandler MainWin.Fuentes.PropertyChanged, AddressOf Fuentes_PropertyChanged
MainWin.Fuentes.RecargarFontSize()
End If
Catch ex As Exception
My.Log.WriteEntry(ex.Message, TraceEventType.Critical)
End Try
End Sub
错误可能是你有什么事情你Load
事件的用户控件中做 - 甚至当窗体加载使用由设计师,不仅在运行时在此事件触发。
如果是这样的话,比你的Load方法添加
if (!System.ComponentModel.DesignerProperties.GetIsInDesignMode)
{
// ...your code
}
的解释here
感谢您的回答,但我没有关于加载事件的任何代码 – 2010-11-10 15:21:59
您的ItemParte控件的构造函数中是否有任何代码? – 2010-11-10 15:55:01
是的!我得到这个: – 2010-11-10 16:00:57
是否有错误堆栈跟踪? – 2010-11-10 14:10:14
你使用VS 2008吗? – Crispy 2010-11-10 14:22:03
@Chris它是一个Visual Studio 2010 Express @Steve我在哪里可以得到它? – 2010-11-10 14:38:11