Click here to Skip to main content
15,445,757 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
i am working on a project and need to stream video through mvvm pattern.i got video in code behind.but i can't get video in mvvm pattern.

in xaml for button and image control :-

<Button Command="{Binding StartCommand}"  Content="Start" Grid.Row="4" Height="38"      Margin="9" Name="btnwebcamstart"  Width="{StaticResource btnWidth}"/>

<Image Source="{Binding Source=Imagevideo}"   Margin="9" Name="patientvideo" Stretch="Fill"  Width="120" Grid.RowSpan="2" Height="104" Grid.Row="1" />

i just make one image property:

public Image Imagevideo
               return imagevideo;
               imagevideo = value;

WebCam is a .cs file .
in constructor i write:-

WebCam webcam=new webcam();
   webcam.InitializeWebCam(ref  Imagevideo);
   this.StartCommand = new DelegateCommand<object>(this.patientvideostart);
   public void InitializeWebCam(ref System.Windows.Controls.Image ImageControl)
           webcam = new WebCamCapture();
           webcam.FrameNumber = ((ulong)(0ul));
           webcam.TimeToCapture_milliseconds = FrameNumber;
           webcam.ImageCaptured += new WebCamCapture.WebCamEventHandler(webcam_ImageCaptured);
           _FrameImage = ImageControl;
     void webcam_ImageCaptured(object source, WebcamEventArgs e)
           _FrameImage.Source = LoadBitmap((System.Drawing.Bitmap)e.WebCamImage);
    public static BitmapSource LoadBitmap(System.Drawing.Bitmap source)

           ip = source.GetHbitmap();

           bs = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(ip, IntPtr.Zero, System.Windows.Int32Rect.Empty,



           return bs;


i just call one start method from .cs file

public void patientvideostart(object parameter)


//webcam.InitializeWebCam(ref  Imagevideo);

in code behind "ref imagevideo" is a image control .i changed to a property"ref Imagevideo".so in here i got the error.
"A property,indexer or dynamic member access may not be passed as an out or ref parameter"

what i can do for getting the video streaming in mvvm.advance thanks..
<pre lang="c#">

1 solution


The error is pretty clear - you can't pass a property to a ref parameter of a method.

You need to make a temporary:

var circle = painting.Circles[mutationIndex];
MutatePosition(ref circle, painting.Width, painting.Height);
painting.Circles[mutationIndex] = circle;

That being said, mutable structs are often a bad idea. You might want to consider making this a class instead of a struct.

Have a look at the following CP article: Using YouTube API with MVVM-Light-Toolkit[^] - it might shed some light on the issue.

Kind regards,
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900