Ignoring Elements and Attributes

Sometimes you want to insert some XAML into a view, but have it ignored at runtime. You can do so with the Ignorable attached property, from the markup compatibility namespace. You use this property to specify which namespace prefixes the XAML processor should ignore. You might have noticed that this is defined in all new XAML files, and is used to instruct the XAML processor to ignore the design-time properties from the Expression Blend namespace. Say you have the following XAML, which simply contains a Label control:

<UserControl x:Class="AdventureWorks.TestView"     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"     xmlns:d="http://schemas.microsoft.com/expression/blend/2008" ...

Get Pro Business Applications with Silverlight 5 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.