diff options
author | Eric Maupin <ermaup@microsoft.com> | 2018-06-28 20:13:10 +0300 |
---|---|---|
committer | Eric Maupin <ermaup@microsoft.com> | 2018-07-19 00:20:56 +0300 |
commit | a2e13f010fbfde27faf10c071663acdf5a12ed03 (patch) | |
tree | a10b8fd771d29a862f0124b6f23195e48def7e60 /Xamarin.PropertyEditing.Windows | |
parent | 05bdfa2bc419204afef8005b997e903a8373fb5a (diff) |
[Win] Don't throw on missing components in design mode
Because the template is a dynamic load, the parts are missing. We
shouldn't throw while in design mode in this case since it just mucks up
the designer.
Diffstat (limited to 'Xamarin.PropertyEditing.Windows')
-rw-r--r-- | Xamarin.PropertyEditing.Windows/TextBoxEx.cs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/Xamarin.PropertyEditing.Windows/TextBoxEx.cs b/Xamarin.PropertyEditing.Windows/TextBoxEx.cs index 867021c..295ea32 100644 --- a/Xamarin.PropertyEditing.Windows/TextBoxEx.cs +++ b/Xamarin.PropertyEditing.Windows/TextBoxEx.cs @@ -1,4 +1,5 @@ using System; +using System.ComponentModel; using System.Windows; using System.Windows.Controls; using System.Windows.Input; @@ -71,10 +72,14 @@ namespace Xamarin.PropertyEditing.Windows public override void OnApplyTemplate () { base.OnApplyTemplate (); - + var clear = GetTemplateChild ("PART_Clear") as Button; - if (clear == null) - throw new InvalidOperationException ("PART_Clear must be present as a button"); + if (clear == null) { + if (!DesignerProperties.GetIsInDesignMode (this)) + throw new InvalidOperationException ("PART_Clear must be present as a button"); + + return; + } clear.Click += (sender, e) => { Clear(); |