Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,845 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I tried a video SDK and got a example code written in C#,WPF below, it shows video stream on screen.
the point is, it used the context variable and assigned PublisherVideo(a control in xaml) to Renderer
I want to rewite it by MVVM pattern, is there any proper way to do this?
I can just bind a property of control to a variable, but don't know how to get control in viewModel...
MainWindow.xaml.cs
public MainWindow()
{
InitializeComponent();
context = new Context(new WPFDispatcher());
Publisher = new Publisher.Builder(context)
{
Capturer = capturerDevices[0].CreateVideoCapturer(VideoCapturer.Resolution.High, VideoCapturer.FrameRate.Fps30),
Renderer = PublisherVideo
}.Build();
}
xaml
<Window x:Class="BasicVideoChat.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:BasicVideoChat"
xmlns:OpenTok="clr-namespace:OpenTok;assembly=WPFVideoRenderer"
mc:Ignorable="d"
Title="MainWindow" Height="960" Width="640">
<Grid>
<OpenTok:VideoRenderer x:Name="PublisherVideo" HorizontalAlignment="Center" Height="480" VerticalAlignment="Top" Width="640">
</OpenTok:VideoRenderer>
<OpenTok:VideoRenderer x:Name="SubscriberVideo" HorizontalAlignment="Center" Height="480" VerticalAlignment="Bottom" Width="640">
</OpenTok:VideoRenderer>
</Grid>
</Window>