2011-11-07 69 views
0

所以我试图使用Databinding的TagLib库,但我有麻烦把它变成一个可绑定的属性。任何帮助表示赞赏,谢谢。这里是我到目前为止,我不明白我在做什么错:与TagLib的数据绑定#

public TagLib.File fileToEdit 
    { 
     get { return (TagLib.File)GetValue(fileToEditProperty); } 
     set { SetValue(fileToEditProperty, value); } 
    } 

    // Using a DependencyProperty as the backing store for fileToEdit. This enables animation, styling, binding, etc... 
    public static readonly DependencyProperty fileToEditProperty = 
     DependencyProperty.Register("fileToEdit", typeof(TagLib.File), typeof(TagLib.File), new UIPropertyMetadata(TagLib.File.Create("",TagLib.ReadStyle.None))); 

回答

0

DependencyProperty.Register有两个Type参数。第一个代表物业的类型(TagLib.File)。第二种是你的(你没有列出,所以我不能告诉你是什么)类型。将第二个参数更改为typeof(YourClass),并且您应该能够绑定您的属性并在代码中使用它。

+0

啊,现在它工作得好多了,但是我现在从最后一部分得到了不受支持的格式异常。我不知道如何解决这个问题。有任何想法吗? @亚当罗宾逊 – kmaz13

+0

我不确定;我需要更多信息。你最好的办法是尽可能多地收集信息(发生异常,堆栈跟踪,你正在做什么等)并发布另一个问题。 –

+0

好的,会做的。感谢您的建议! – kmaz13