bircastri
bircastri

Reputation: 153

Binding element WPF application

I have this code.

<MediaElement x:Name="VideoControl" Width="Auto" Height ="{Binding altezza}"
   Source="intro.avi" LoadedBehavior="Manual" UnloadedBehavior="Stop">
</MediaElement>

In the .cs file I have this method

public int altezza{
   get { return 150; }
}

But it's not called from WPF element.

How I can fix it?

Thanks you for your reply

Upvotes: 0

Views: 51

Answers (1)

Flat Eric
Flat Eric

Reputation: 8111

You must set the Datacontext to your Codebehind file:

DataContext="{Binding RelativeSource={RelativeSource Self}}"

Upvotes: 2

Related Questions