locked
MediaElement GridView RRS feed

  • Question

  • Hi

    I was wondering if a Media Element could be a GridView Item? Meaning if I am using a GridView item template, can the items contain a MediaElement control individually?

    Thank you

    Tuesday, March 19, 2013 4:14 AM

Answers

  • Yes.  It was really easy to test this.

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Tuesday, March 19, 2013 2:51 PM
    Moderator

All replies

  • Yes.  It was really easy to test this.

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Tuesday, March 19, 2013 2:51 PM
    Moderator
  • Hi Matt

    I have finally got around to trying this. In the DataTemplate I have changed the image source to a MediaElement, see below.

     Back in the Gridview I call the itemClick event, and can reference what item has been clicked. This will usually navigate to the appropriate page, but sometimes I want to play a video or sound in the item.

    How to I reference the MediaElement so I can attach a source?

    Thanks!

      <!--  <Image Source="{Binding Thumbnail}" Stretch="UniformToFill" HorizontalAlignment="Center" VerticalAlignment="Center" /> -->
     <MediaElement PosterSource="{Binding Thumbnail}" VerticalAlignment="Center" HorizontalAlignment="Center" Name="myMediaElement"  RealTimePlayback="True" Height="250" Width="250" />
     private void ItemView_ItemClick(object sender, ItemClickEventArgs e)
            {
                // Navigate to the appropriate destination page, configuring the new page
                // by passing required information as a navigation parameter
                var itemId = ((PictureViewModel)e.ClickedItem).UniqueId;
                var itemGroupId = ((PictureViewModel)e.ClickedItem).Group.UniqueId;
    
              
                
                if (itemGroupId == 1)            {
                    this.Frame.Navigate(typeof(SplitPageFirst), itemId);
                    return;
                
            
                
           
                }




    • Edited by Andy Sid Saturday, June 8, 2013 3:16 AM
    Saturday, June 8, 2013 3:13 AM