Conditionnel XAML (WPF)

Je suis en train de créer un Contrôle Utilisateur qui, selon le mode de l'utilisateur définit dans la Propriété de Dépendance, les changements à l'Utilisateur de Contrôler à un TextBlock et un autre TextBlock ou un TextBlock et une zone de texte. Je sais que les propriétés de dépendance obtenez de l'information, mais le problème se pose lorsque je tente de régler le bon modèle. Pour une raison quelconque, le modèle ne rend pas correctement.

XAML:

<UserControl x:Class="BookOrganizer.FlipBox"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
         xmlns:my="clr-namespace:BookOrganizer"
         mc:Ignorable="d" 
         d:DesignHeight="300" d:DesignWidth="300">
<StackPanel Orientation="Horizontal" Height="Auto" Width="Auto" >
    <StackPanel.Resources>
        <ContentControl x:Key="Box">
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="{Binding Path=Title}" Height="Auto" Width="Auto" />
                <TextBox Text="{Binding Path=Text}" Height="Auto" Width="Auto" />
            </StackPanel>
        </ContentControl>
        <ContentControl x:Key="Block" Height="Auto" Width="Auto">
            <StackPanel Orientation="Horizontal" Height="Auto" Width="Auto">
                <TextBlock Text="{Binding Path=Title}" Height="Auto" Width="Auto" />
                <TextBlock Text="{Binding Path=Text}" Height="Auto" Width="Auto"/>
            </StackPanel>
        </ContentControl>
    </StackPanel.Resources>
    <ContentControl Template="{Binding Path=BoxMode}" />
</StackPanel>

Code Derrière:

using System;
using System.Windows;
using System.Windows.Controls;

namespace BookOrganizer
{
    ///<summary>
    ///Interaction logic for FlipBox.xaml
    ///</summary>
    public partial class FlipBox : UserControl
    {
        public static readonly DependencyProperty TitleProperty = DependencyProperty.Register(
        "Title", typeof(String), typeof(FlipBox), new PropertyMetadata("nothing"));

        public static readonly DependencyProperty TextProperty = DependencyProperty.Register(
        "Text", typeof(String), typeof(FlipBox), new PropertyMetadata("nothing"));

        public static readonly DependencyProperty BoxModeProperty = DependencyProperty.Register(
        "BoxMode", typeof(String), typeof(FlipBox), new PropertyMetadata("Box"));

        public FlipBox()
        {
            InitializeComponent();
            this.DataContext = this;
        }

        public String Title
        {
            get { return (String)this.GetValue(TitleProperty); }
            set { this.SetValue(TitleProperty, value); }
        }

        public String Text
        {
            get { return (String)this.GetValue(TextProperty); }
            set { this.SetValue(TextProperty, value); }
        }

        public String BoxMode
        {
            get { return (String)this.GetValue(BoxModeProperty); }
            set { this.SetValue(BoxModeProperty, value); }
        }

    }
}

Merci d'avance.

Définir "ne rend pas correctement". Quel est le résultat attendu et qu'est-ce que la sortie réelle?
Le résultat attendu serait soit un Bloc de Texte et un autre Bloc de Texte ou un Bloc de Texte et une Zone de Texte. Ce que j'ai est une boîte avec un cercle rouge et un X blanc à l'intérieur du cercle ou rien. Basé sur la façon dont j'essaie de le lancer.

OriginalL'auteur chris | 2011-02-02