使用 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)));
So I'm trying to use the TagLib library with Databinding but I'm having trouble turning it into a property that is bindable. Any help is appreciated, thanks. Here is what I have so far, I don't understand what I'm doing wrong:
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)));
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
DependencyProperty.Register
采用两个Type
参数。第一个表示属性的类型 (TagLib.File
)。第二个采用您的类的类型(您没有列出,所以我无法告诉您那是什么)。将第二个参数更改为typeof(YourClass)
,您应该能够绑定您的属性并在代码中使用它。DependencyProperty.Register
takes twoType
parameters. The first represents the type of the property (TagLib.File
). The second takes the type of your class (which you don't have listed, so I can't tell you what that is). Change the second argument to betypeof(YourClass)
and you should be able to bind your property and use it in code.