×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Dec 2012
    Location
    Germany
    Posts
    2

    Question VideoBrush.SetSource(PhotoCaptureDevice) in ViewModel? (MVVM)

    Hi,

    I'm trying to bin a bind a VideoBrush in my ViewModel to a Canvas Backround. I want to fill the VideoBrush with a PhotoCaptureDevice.

    When I'm doing that in the CodeBehind it's working fine What am I not seeing here?

    Can anyone help me?



    Code:
    // Setting the VideoBrush Source to the PhotoCaptureDevice
    
    PhotoCaptureDevice CaptureDevice = await PhotoCaptureDevice.OpenAsync(CameraSensorLocation.Back, _captureResolution);
    
    PreviewVideoBrush = new VideoBrush();
    PreviewVideoBrush.SetSource(CaptureDevice); // Here is the first Problem. It accepts only MediaElement and CaptureSource that way
    
    
    // Property with Change Notification
    
    private VideoBrush _previewVideoBrush;
    public VideoBrush PreviewVideoBrush
    {
        get { return _previewVideoBrush; }
        set
        {
            if (Equals(value, _previewVideoBrush)) return;
            _previewVideoBrush = value;
            OnPropertyChanged();
        }
    }

    Code:
    <!-- XAML -->
    
    Grid x:Name="LayoutRoot" Background="Transparent">
            <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
                <Canvas Background="{Binding PreviewVideoBrush}" />
            </Grid>
        </Grid>

  2. #2
    Registered User
    Join Date
    Jul 2013
    Posts
    1

    Re: VideoBrush.SetSource(PhotoCaptureDevice) in ViewModel? (MVVM)

    Just add the following "using" to your code file:

    Code:
    using Microsoft.Devices;

  3. #3
    Nokia Developer Champion
    Join Date
    Sep 2012
    Location
    Morocco
    Posts
    296

    Re: VideoBrush.SetSource(PhotoCaptureDevice) in ViewModel? (MVVM)

    Hello,

    I've just tryed it using this code and it worked

    Code:
    PhotoCamera cam = new PhotoCamera(CameraType.Primary); // or FrontFacing
    
                PreviewVideoBrush = new VideoBrush();
                PreviewVideoBrush.SetSource(cam); //

Similar Threads

  1. PhotoCaptureDevice - Error when NavigatingFrom and then NavigatingTo
    By fabianhenzler in forum Windows Phone General
    Replies: 4
    Last Post: 2013-07-01, 16:19
  2. Replies: 2
    Last Post: 2012-01-28, 08:12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×