XamlParseException Fehler beim Zuweisen zur Eigenschaft. Bindung funktioniert nicht mit angehängter Eigenschaft

Ich möchte ein benutzerdefiniertes Textfeld mit angehängter Eigenschaft für die Windows Store-App erstellen. Ich folgediese Lösung. Jetzt wird ein fest codierter Wert als Eigenschaftswert verwendet, aber ich möchte den Wert mithilfe der Bindung festlegen, aber dies funktioniert nicht. Ich habe versucht viel zu suchen, aber mir hat keine Lösung geholfen.

Die Ausnahmedetails sind wie folgt

In CustomTextBox.exe ist eine Ausnahme vom Typ "Windows.UI.Xaml.Markup.XamlParseException" aufgetreten, die jedoch im Benutzercode nicht behandelt wurde

WinRT-Informationen: Zuweisung zur Eigenschaft 'CustomTextBox.Input.Type' fehlgeschlagen.

MainPage.xaml

<!-- local:Input.Type="Email" works -->
<!-- local:Input.Type="{Binding SelectedTextboxInputType}" not working -->

<TextBox x:Name="txt" local:Input.Type="{Binding SelectedTextboxInputType}" Height="30" Width="1000" />

<ComboBox x:Name="cmb"  ItemsSource="{Binding TextboxInputTypeList}" SelectedItem="{Binding SelectedTextboxInputType}" Height="30" Width="200" 
          Margin="451,211,715,527" />

MainPage.xaml.cs

public sealed partial class MainPage : Page
{
    public MainPage()
    {
        this.InitializeComponent();
        DataContext = new ViewModel();
    }
}

Input.cs

//InputType is enum
public static InputType GetType(DependencyObject obj)
{
    return (InputType)obj.GetValue(TypeProperty);
}

public static void SetType(DependencyObject obj, InputType value)
{
    obj.SetValue(TypeProperty, value);
}

public static readonly DependencyProperty TypeProperty =
    DependencyProperty.RegisterAttached("Type", typeof(InputType), typeof(TextBox), new PropertyMetadata(default(InputType), OnTypeChanged));

private static void OnTypeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
    if (e.NewValue is InputType)
    {
        var textBox = (TextBox)d;
        var Type = (InputType)e.NewValue;
        if (Type == InputType.Email || Type == InputType.URL)
        {
            textBox.LostFocus += OnLostFocus;
        }
        else
        {
            textBox.TextChanged += OnTextChanged;
        }
    }
}

ViewModel.cs

public class ViewModel : BindableBase
{
    public ViewModel()
    {
        TextboxInputTypeList = Enum.GetValues(typeof(InputType)).Cast<InputType>();
    }

    private InputType _SelectedTextboxInputType = InputType.Currency;
    public InputType SelectedTextboxInputType
    {
        get { return _SelectedTextboxInputType; }
        set { this.SetProperty(ref this._SelectedTextboxInputType, value); }
    }

    private IEnumerable<InputType> _TextboxInputTypeList;
    public IEnumerable<InputType> TextboxInputTypeList
    {
        get { return _TextboxInputTypeList; }
        set { this.SetProperty(ref this._TextboxInputTypeList, value); }
    }
}

Antworten auf die Frage(2)

Ihre Antwort auf die Frage