Click here to Skip to main content
15,355,537 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 :-

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

XML
<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:

C#
public Image Imagevideo
       {
           get
           {
               return imagevideo;
           }
           set
           {
               imagevideo = value;
               OnPropertyChaged("Imagevideo");
           }
       }


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

C#
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,

               System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions());

           DeleteObject(ip);

           return bs;

       }

i just call one start method from .cs file

C#
public void patientvideostart(object parameter)
       {

           webcam.Start();
       }

C#
//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..
C#
<pre lang="c#">
Posted

1 solution

Hi,

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

You need to make a temporary:

C#
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 1.9.0.0 with MVVM-Light-Toolkit[^] - it might shed some light on the issue.

Kind regards,
   

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


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