Using the MediaElement in the TouchablePanel

Jul 2, 2009 at 1:57 PM

Any ideas on using the media element in the touchable panel. When ever I use it it the whole app craches. Is there something special I have to do?

Matt

Jul 2, 2009 at 4:38 PM

any more detail about the crash?

Jul 3, 2009 at 7:15 AM

Here's the XAML

<mt:Window x:Class="MultiTouchTest.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"    
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:mt="http://schemas.multitouch.com/Multitouch/2008/04"
           xmlns:sys="clr-namespace:System;assembly=mscorlib"
    Title="Window1" Height="1000" Width="1000">
    <Grid>
        <!--<ItemsControl ItemsSource="{Binding Photos}">
            <ItemsControl.Resources>
                <DataTemplate DataType="{x:Type sys:String}">
                    <Image Source="{Binding}"/>
                </DataTemplate>
            </ItemsControl.Resources>
            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <mt:TouchablePanel/>
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
        </ItemsControl>-->
        <mt:TouchablePanel>

            <TextBlock Text="Testing Touch" FontSize="72" Foreground="White" Background="BlueViolet"/>
            <Image Source="getafix.jpg"/>
            <mt:Button Content="Testing Button" Height="50" Width="50"/>
            <MediaElement Source="Wildlife.wmv" x:Name="Vid2" Height="300" Width="300"/>
            <!--<MediaElement Source="MicrosoftSurfacing_on10.wmv" LoadedBehavior="Play"  />-->
        </mt:TouchablePanel>
   
    </Grid>
</mt:Window>

Without the media element it works great with it I get a message box in visual studio saying "There is no source code available for the current location" then when I hit ok i get a visual studio debuggin error saying "ArgumentOutOfRangeException was unhandled" Details of the error are "Must be greater than 0 , parameter width". I tried giving the media element a specific width and height in the hope of rectifying it but no luck. Any ideas. By the way im running this on Windows 7 RC in VS2008 SP1 Team System.

Matthew

 

Coordinator
Jul 4, 2009 at 10:14 AM

TouchablePanel has issues with elements that change it's size. MediaElement is loaded initialy with size 0,0 and then resized to match the size of the media. Try to place MediaElement in some container, like border. And give it some fixed size.

Jul 6, 2009 at 10:35 AM

I trie using a border and a stack panel but still not luck. The whole app doesnt crash now but I dont see the video. All the other controls work just fine. Any more advice?

Coordinator
Jul 7, 2009 at 6:05 PM

Have you set fixed size on border?

Jul 8, 2009 at 6:47 AM

I did set the border & the stack panel to a fixed size the first time an still no luck.