UserControl必须实现ISupportInitialize接口.
/// <summary>
/// Implement ISupportInitialize so that the Initialized event can be attached in XAML.
/// A known bug is that the BeginInit/EndInit will be called twice in WPF 3.*.
/// </summary>
public partial class UcTaskItemNote : ISupportInitialize
{
private int mInitCalledCount = 0;
#region ISupportInitialize Members
void ISupportInitialize.BeginInit()
{
if(this.mInitCalledCount == 0)
{
return;
}
base.BeginInit();
}
void ISupportInitialize.EndInit()
{
if (this.mInitCalledCount == 0)
{
this.mInitCalledCount++;
return;
}
base.EndInit();
}
#endregion
}
/// Implement ISupportInitialize so that the Initialized event can be attached in XAML.
/// A known bug is that the BeginInit/EndInit will be called twice in WPF 3.*.
/// </summary>
public partial class UcTaskItemNote : ISupportInitialize
{
private int mInitCalledCount = 0;
#region ISupportInitialize Members
void ISupportInitialize.BeginInit()
{
if(this.mInitCalledCount == 0)
{
return;
}
base.BeginInit();
}
void ISupportInitialize.EndInit()
{
if (this.mInitCalledCount == 0)
{
this.mInitCalledCount++;
return;
}
base.EndInit();
}
#endregion
}