문제

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