2

내 프로젝트에 한 페이지가 있습니다.이 페이지는 배경을 변경합니다. 사용자가 화면을 터치 할 때 자산의 임의의 이미지로 속성을 변경하지만 변경시 페이지 배경이 검은 색 또는 흰색으로 0.05 초 전에 변경됩니다. 내 이미지로 변경하십시오. 너무 못 생겼어. 여기 이미지 변경 끔찍한 페이지 배경 변경시

는 CS에서 내 코드

private void LayoutRoot_ManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs e) 
    { 
     Random ran = new Random(); 
     randomPage.Background = new ImageBrush 
     { 
      ImageSource = 
       new BitmapImage { UriSource = new Uri("ms-appx:///Assets/Backgrounds/" + ran.Next(22) + ".jpg") } 
     }; 

     e.Handled = true; 
    } 

파일입니다 제가 이미지 페이지 배경이 원활하게 변경하기 위해 무엇을 할 수 있는가?

+0

짧은 애니메이션을 만들어 이미지를 0 % 불투명도로 사라지게하고 이미지를 전환 한 다음 다시 100 %로 되돌릴 수 있습니까? –

답변

1

대신 StoryBoard 애니메이션을 사용해보세요.

예제 코드는 경우에 Image

<Image Stretch="Uniform" Name="myImage" Source="/Images/w1.png" /> 

<Storyboard x:Name="Storyboard1"> 
    <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(Image.Source)" Storyboard.TargetName="myImage" RepeatBehavior="Forever"> 
     <DiscreteObjectKeyFrame KeyTime="0" Value="="/Images/w1.png"></DiscreteObjectKeyFrame> 
     <DiscreteObjectKeyFrame KeyTime="0:0:1" Value="="/Images/w2.png"></DiscreteObjectKeyFrame> 
     <DiscreteObjectKeyFrame KeyTime="0:0:2" Value="="/Images/w3.png"></DiscreteObjectKeyFrame> 
     <DiscreteObjectKeyFrame KeyTime="0:0:3" Value="="/Images/w4.png"></DiscreteObjectKeyFrame> 
     <DiscreteObjectKeyFrame KeyTime="0:0:4" Value="="/Images/w5.png"></DiscreteObjectKeyFrame> 
    </ObjectAnimationUsingKeyFrames> 
</Storyboard> 

Storyboard1.Begin(); 

당신이 아마 코드 숨김에서 StoryBoard을 만들고 임의 속성을 설정하려는 애니메이션합니다. 한 프레임에서 다른 프레임으로 애니메이션을 "편하게"조율하여 디스플레이를 부드럽게 할 수도 있습니다.

+0

작동하지 않습니다. WP 8.1 RT를 사용하고 있습니다! –

+0

@BoltDelta는 런타임을 위해 StoryBoard를 검색하고 코드를 주변에 맞게 변경합니다. 거의 동일합니다. –

+0

고맙습니다. 나는 FlipView로 이미 내 문제를 해결했다. 나는 그것을 모른다 : D –