Preventing WPF Controls from Being Displayed in the Visual Studio Toolbox

In other technologies such as Windows Forms and Web Forms, you can adorn a class with the [ToolboxItem(false)] attribute and it will not appear in the Visual Studio Toolbox.


In Windows Presentation Foundation (WPF) you use the [ToolboxBrowsable(false)] attribute instead. This attribute is found in the Microsoft.Windows.Design namespace in the Microsoft.Windows.Design.dll assembly.


Best Regards,
Kevin McNeish
.NET MVP for past seven years
INETA Speaker
Chief Architect,  MM .NET Application Framework
www.oakleafsd.com

Fixing WPF TextBox Mouse Events Not Firing

If you create a handler for the WPF TextBox’s mouse events, you will find that the code in your handler never fires. This is because the event is marked as “handled” in the .NET Framework, so it never reaches your code.


To get around this bad behavior, you can use the TextBox’s AddHandler() method to register your handler method, passing a true for the handledEventsToo parameter. For example:


this.txtCustomerID.AddHandler(ControlMouseLeftButtonUpEvent, 
    new MouseButtonEventHandler(txtCustomerID_MouseLeftButtonUp), true);

Best Regards,


Kevin McNeish
INETA Speaker
Chief Architect, MM .NET Application Framework
http://www.oaleafsd.com


 

Fixing "Configuration System Failed to Initalize" Exception

If you see the “Configuration System Failed to Initialize” exception at run time, it is typically caused by an invalid entry in your app.config or web.config file. In my case, I encountered this exception when I had an “<add key…>” element out of place. Oddly enough, the compiler didn’t warn me about this when I rebuilt my solution with the config file open (as it usually does with most other config file errors).


Best Regards,
Kevin McNeish
INETA Speaker
Microsoft .NET MVP 2002-2009
Chief Architect, MM .NET Application Framework
www.oakleafsd.com