Вот как выглядит мой OnApplyTemplate
:
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
if (DesignerProperties.IsInDesignTool) return;
this.partTextBox = this.GetTemplateChild(PartTextBox) as TextBox;
this.partButton = this.GetTemplateChild(PartButton) as Button;
if (this.partTextBox == null || this.partButton == null)
{
throw new NullReferenceException("Template part(s) not available");
}
this.partTextBox.LostFocus += this.OnTextBoxLostFocus;
this.partButton.Click += this.OnButtonClick;
if (this.DataProvider == null)
{
throw new NotSupportedException("DataProvider wasn't specified");
}
Вторая строка, где я проверяю IsInDesignTool, выдает мне сообщение о том, что я не могу получить доступ к внутреннему классу "DesignerProperties" здесь.
В основном, когда я перетаскиваю свой элемент управления из панели инструментов в представление в дизайне, возникает исключение, потому что DataProvider не указан.Итак, мне нужно отключить этот код на время разработки.
Как мне это сделать?