Updating WPFToolkit source Code

Jan 6, 2010 at 11:59 AM

I have downloaded WPFToolkit and made the changes to make Watermark property(DatePicker) of accessible. I am getting following error message when opening XAML files to in Visual Studio:

An unhandled exception has occuered

Click here to reload designer

Index was outside the bounds of the array.

   at System.RuntimeTypeHandle.GetDeclaringType()
   at System.RuntimeType.RuntimeTypeCache.GetEnclosingType()
   at System.RuntimeType.get_DeclaringType()
   at MS.Internal.Xaml.AssemblyNode.BuildNamespaces()
   at MS.Internal.Xaml.AssemblyNode.FindNamespace(Identifier name)
   at MS.Internal.Xaml.ReflectionProjectNode.BuildNamespaces()
   at MS.Internal.Xaml.ReflectionProjectNode.Find(Identifier namespaceUri)
   at MS.Internal.Xaml.PrefixScope.AddIgnorablePrefix(Identifier prefix)
   at MS.Internal.Xaml.XmlElement.BuildScope(PrefixScope parentScope, IParseContext context)
   at MS.Internal.Xaml.XmlElement.FindElementType(PrefixScope parentScope, IParseContext context)
   at MS.Internal.DocumentTrees.Markup.XamlSourceDocument.get_RootType()
   at Microsoft.Windows.Design.Documents.Trees.MarkupDocumentTreeManager.get_RootType()
   at Microsoft.Windows.Design.Documents.MarkupDocumentManager.CalculateLoadErrorState()
   at Microsoft.Windows.Design.Documents.MarkupDocumentManager.get_LoadState()
   at MS.Internal.Host.PersistenceSubsystem.Load()
   at MS.Internal.Host.Designer.Load()
   at MS.Internal.Designer.VSDesigner.Load()
   at MS.Internal.Designer.VSIsolatedDesigner.VSIsolatedView.Load()
   at MS.Internal.Designer.VSIsolatedDesigner.VSIsolatedDesignerFactory.Load(IsolatedView view)
   at MS.Internal.Host.Isolation.IsolatedDesigner.BootstrapProxy.LoadDesigner(IsolatedDesignerFactory factory, IsolatedView view)
   at MS.Internal.Host.Isolation.IsolatedDesigner.BootstrapProxy.LoadDesigner(IsolatedDesignerFactory factory, IsolatedView view)
   at MS.Internal.Host.Isolation.IsolatedDesigner.Load()
   at MS.Internal.Designer.DesignerPane.LoadDesignerView()

Jan 12, 2010 at 8:43 PM

Hi pardeepbogra -

Can you share a snippit of the changes you made?

Thank you,

Eric, MSFT

Jan 13, 2010 at 8:01 AM

I performed the following steps:

1.  Get source code.
2.  Add the following dependency property to the DatePicker.cs file:  (I added in #Data region)
            public static DependencyProperty WatermarkProperty = DependencyProperty.Register( "Watermark", typeof( string ), typeof( DatePicker ), new PropertyMetadata( "Show Calendar" ) );
            public string Watermark
                get { return ( string ) GetValue( WatermarkProperty ); }
                set { SetValue( WatermarkProperty, value ); }

3.  Replace existing SetWatermarkText() with the following:
            private void SetWaterMarkText()
                if (this._textBox != null)
                    this._defaultText = string.Empty;
                    this._textBox.Watermark = Watermark;

4.  Recompile WPFToolkit and replace the existing WPFToolkit.DLL with new one.

Jan 13, 2010 at 7:44 PM
Edited Jan 13, 2010 at 7:45 PM

Hi pardeepbogra -

I've added a new project (consisting of a Window with a DatePicker in it) to the WPFToolkit solution and added a reference to the WPFToolkit project to my new project. After replicating your changes to DatePicker.cs I was unable to reproduce your issue. To be clear, when you un-do your modifications to SetWaterMarkText, everything compiles? If you wish to simply modify the Watermark, there are other (less flexible) approaches that do not involve code such as changing the Template for the DatePickerText box to use a hard coded String instead of a Binding to the Watermark property.

-Eric, MSFT

Oct 22, 2010 at 1:30 PM

Hi, was there any final resolution to this issue? I am suddenly getting exactly the same error whenever I open the designer, even for a blank UserControl. It's very annoying.