Motivated Motivated - 6 months ago 51
C# Question

Bind to property of object

I am currently developing a little musicplayer just for fun.
I was wondering if I can bind to a class named Track and access its propertys in XAML.

public class Track
public string TitleName { get; set; }
public BitmapImage Cover { get; set; }

Code can explain better than I can so here's my pseudo code:

<Image Source="{Binding BindingName="CurrentTrack" PropertyName="Cover"}"/>
<TextBlock Text="{Binding BindingName="CurrentTrack" PropertyName="Title"}"/>

Can I get something like this without using a Converter or sth like that ?


You can access a child property like this:

<TextBox Text="{Binding CurrentTrack.TitleName}"/>

You must have bound your View to your ViewModel