I’m trying to make a binding of a medialElement from MainView.xaml to a ViewModel’s proprety.
in MainViewModel.cs we would find
#region Media
private MediaElement media;
public MediaElement Media
{
get
{
return media;
}
set
{
if (value == media)
return;
media = value;
OnPropertyChanged("Media");
}
}
#endregion
I would like to know what to put in the MainView.xaml to do the binding.
I know that if it were a TextBox I would write
`<TextBox Text="{Binding BGToSet, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" />`
But what should i do for MediaElement ?
i now do this :
`<MediaElement VerticalAlignment="Center" Width="700" LoadedBehavior="Manual" Height="450" Stretch="Fill" MediaOpened="{ Binding mediaMediaOpenedCommand}" >
`
Thanks a lot for your answer !! Sorry for my english. i’m also new in WPF
You should either expose
Uriof media source you want to show instead ofMediaElement:or use
ContentControl(orContentPresenter) to showMediaElementitself: