0

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)));
kmaz13
  • 260
  • 1
  • 5
  • 14

1 Answers1

0

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.

Adam Robinson
  • 182,639
  • 35
  • 285
  • 343
  • Ahh, it's working much better now, however I'm getting an unsupported format exception from the last part now. I have no idea how to work around that. Any ideas? @Adam Robinson – kmaz13 Nov 07 '11 at 02:48
  • I'm not sure; I'd need more info. Your best bet is to gather as much information as you can (where the exception occurs, the stack trace, what you're doing, etc.) and post another question. – Adam Robinson Nov 07 '11 at 03:08