8/17/2008

How to reference WPF types in XAML

1. If the custom WPF types had been defined in your WPF application, you can reference it in your XAML by adding the BOLD line append to XAML root element:
<Window x:Class="WpfApplication1.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:custom="clr-namespace:WpfApplication1"
    Title="Window1">
...
</Window>

2. If the WPF types had been defined outside your WPF application, you can append "assembly" clause to "clr-namespace:xxx" and spearate "clr-namespace" and "assembly" clauses by semicolon:
<Window x:Class="WpfApplication1.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:custom2="clr-namespace:WpfCustomControlLibrary1;assembly=WpfCustomControlLibrary1"
    Title="Window1">
...
</Window>

3. The <?Mapping XmlNamespace="http://your-domain/your-type" ClrNamespace="your-wfp-app-namespace" ?> does not work again that
Ian Griffiths and Chris Sells introduced it in [Programming Windows Presentation Foundation ].

No comments: