Вопрос

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)));
Это было полезно?

Решение

DependencyProperty.Register takes two Type 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 be typeof(YourClass) and you should be able to bind your property and use it in code.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top