尝试根据diff uwp平台保持gif图像的合适性

时间:2016-12-21 13:00:58

标签: c# xaml uwp

我正在尝试按照diff uwp平台设备保持gif图像的合适性。 问题出现在: 1.Gif尺寸不会因不同设备而异。 2.Gif图像第一次出现之后就出现了。

参考给定的ex:On点击“image1Tap” 它会打开common1。 在common1 popup中打开。第一次是gif图像(good_job_1.gif)。正在工作,但第二次它无法正常工作。 究竟是什么问题我没有得到。当我使用png图像而不是gif图像时,功能性很好。任何帮助都将不胜感激。

的Xaml

 <RelativePanel x:Name="contentPanel" Grid.Row="1">
            <Canvas RelativePanel.AlignTopWithPanel="True">
                <Popup x:Name ="ppup" IsOpen = "False" IsLightDismissEnabled = "True"
                         Canvas.Left="100" Canvas.Top="20"
                       >
                    <Image Source = "Assets/good_job_1.gif" Canvas.ZIndex="1" 
                           Stretch="Uniform"/>
                </Popup>
                <Popup x:Name ="ppup1" IsOpen = "False" IsLightDismissEnabled = "True"
                         Canvas.Left="100" Canvas.Top="20"
                   >
                    <Image Stretch="Uniform" Source = "Assets/wrong_answer_1.gif" Canvas.ZIndex="1"  />
                </Popup>
            </Canvas>
<Image x:Name="imgContainer1"
            Source="Assets/Quiz/object_bg.png"              
               Height="190" Width="200"
               RelativePanel.AlignLeftWithPanel="True"
               Margin="10,40,0,0"/>
            <Image x:Name="image1"
            Source="Assets/LearnColor/Object/ob_0_0.png"              
            Height="150" Width="160"
            RelativePanel.AlignLeftWithPanel="True"
            Margin="30,40,0,0"
            Tapped="image1Tap" d:LayoutOverrides="Width, LeftMargin, RightMargin"
               />

C#代码

 private void image1Tap(object sender, TappedRoutedEventArgs e)
        {
            common1();

        }
private void common1()
        {
            string check1 = Headername[CI];
            switch (check1)
            {
                case "Yellow":
                    if ((image1.Source as BitmapImage).UriSource == new Uri("ms-appx:///Assets/LearnColor/Object/ob_0_0.png", UriKind.Absolute) && (objNameWritten1.Text == "Banana"))
                    {
                       // ppup.Height = Window.Current.Bounds.Height;
                        ppup.IsOpen = true;
                        mediaElement1.Source = new Uri("ms-appx:///Audio/wow good job.mp3");
                        mediaElement1.AutoPlay = true;                        

                    }
                    CI++;
                    common();
                    break;

                case "Purple":
                    if ((image1.Source as BitmapImage).UriSource == new Uri("ms-appx:///Assets/LearnColor/Object/ob_3_0.png", UriKind.Absolute) && (objNameWritten1.Text == "Grapes"))
                    {                        
                        ppup.IsOpen = true;
                        mediaElement1.Source = new Uri("ms-appx:///Audio/wow good job.mp3");
                        mediaElement1.AutoPlay = true;
                    }
                    CI++;
                    common();
                    break;               
                case "Green":
                    if ((image1.Source as BitmapImage).UriSource == new Uri("ms-appx:///Assets/LearnColor/Object/ob_6_0.png", UriKind.Absolute) && (objNameWritten1.Text == "Tree"))
                    {                        
                        ppup.IsOpen = true;
                        mediaElement1.Source = new Uri("ms-appx:///Audio/wow good job.mp3");
                        mediaElement1.AutoPlay = true;
                    }
                    CI++;
                    common();
                    break;               
                case "Blue":
                    if ((image1.Source as BitmapImage).UriSource == new Uri("ms-appx:///Assets/LearnColor/Object/ob_9_0.png", UriKind.Absolute) && (objNameWritten1.Text == "Sky"))
                    {                        
                        ppup.IsOpen = true;
                        mediaElement1.Source = new Uri("ms-appx:///Audio/wow good job.mp3");
                        mediaElement1.AutoPlay = true;
                    }
                    CI++;
                    common();
                    break;
                default:                    
                    ppup1.IsOpen = true;
                    mediaElement1.Source = new Uri("ms-appx:///Audio/oh no wrong ans.mp3");
                    mediaElement1.AutoPlay = true;
                    break;
            }
        }

参阅enter image description here

0 个答案:

没有答案