For one of my WPF projects I need to integrate VLC player and I have been playing around with the sample app from this Codeplex Project
However I need to create more than 1 instance of the the player control at runtime and display it setting its various properties. The number of player instances are based on user selection.
I am trying to convert the XAML given in the sample app to its equivalent code behind.
<Wpf:VlcControl x:Name="myVlcControl" />
<Grid Grid.Row="0">
<Grid.Background>
<VisualBrush Stretch="Uniform">
<VisualBrush.Visual>
<Image Source="{Binding ElementName=myVlcControl, Path=VideoSource}" />
</VisualBrush.Visual>
</VisualBrush >
</Grid.Background>
</Grid>
This is what I have gotten to so far
EDIT: Code update after Chen Kinnrot's answer, but the problem persists.
Grid g = new Grid();
VlcControl p = new VlcControl();
p.Media = new PathMedia(@"C:\movie.mkv");
VisualBrush vbr = new VisualBrush();
g.Background = vbr;
vbr.Stretch = Stretch.Uniform;
Binding binding = new Binding("VideoSource");
binding.ElementName = "p";
Image img = new Image();
img.SetBinding(Image.SourceProperty, binding);
vbr.Visual = img;
g.Children.Add(p);
this.grid1.Children.Add(g);
p.Play();
With the above code behind, when I run the app I can hear the movie sound but not see it. I am missing the Image Binding (elementname and path) in my code behind, but don't know how to do it.
Can someone point me to some docs (Googling doesn't produce any good results) or provide pointers to convert the Binding in XAMl to its equivalent code behind?
Many Thanks