我正在爲Window Phone 7.5(芒果)開發Silverlight應用程序。我是一個總新手,這是我的第一個應用程序。當我在模擬器中運行它時,我發現FillRate計數器是4.5或5,紅色。所以這是一個問題。花了一段時間後,我發現我的Main.xaml和其他頁面上的用戶控件已經或者有問題。FillRate並通過Windows Phone Mango中的UserControl設置背景圖像
BackgroundUC.xaml:這由設計師在Blend完成。它有一個從右向左移動的天空圖像。除此之外,我不知道代碼的含義。此控件旨在用作所有頁面上的移動背景。
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" xmlns:eim="clr-namespace:Microsoft.Expression.Interactivity.Media;assembly=Microsoft.Expression.Interactions"
mc:Ignorable="d"
x:Class="MyApp.BackgroundUC"
d:DesignWidth="2872" d:DesignHeight="520">
<UserControl.Resources>
<Storyboard x:Name="sbSkyBg">
<DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="SkyBg" d:IsOptimized="True"/>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateX)" Storyboard.TargetName="SkyBg">
<EasingDoubleKeyFrame KeyTime="0" Value="0"/>
<EasingDoubleKeyFrame KeyTime="0:1:0" Value="-930"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</UserControl.Resources>
<Grid x:Name="LayoutRoot" Background="Transparent">
<Image x:Name="SkyBg" Source="SkyBg.png" Stretch="Fill" d:LayoutOverrides="VerticalAlignment, GridBox" RenderTransformOrigin="0.5,0.5">
<Image.RenderTransform>
<CompositeTransform/>
</Image.RenderTransform>
<i:Interaction.Triggers>
<i:EventTrigger EventName="Loaded">
<eim:ControlStoryboardAction Storyboard="{StaticResource sbSkyBg}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</Image>
</Grid>
</UserControl>
我發現了什麼:如果我不使用此用戶控件,但設置MainPage.xaml中的LayOutRoot電網的Backgrond我的天空圖像(靜態)的填充率下降到1.5。但有了這個,我將不得不在每個頁面上單獨設置網格的背景。而且我不確定如何製作動畫以產生移動的天空效果。
問題: 1:什麼是錯的UC,我怎麼能調整我的UC這樣的填充率爲最佳範圍,即< 2.5的範圍?
2:如果UC本身就是一個問題,那麼在我的場景中最好的方法是什麼,這樣我就可以與一些動畫有共同的背景了?
3:如果我有在個別網頁級像我上面提到的事,我怎麼能動畫背景設置是這樣的:
<Grid.Background>
<ImageBrush ImageSource="/MyApp;component/SkyBg.png" />
</Grid.Background>
我仍然在學習和任何幫助非常感謝。
感謝。我嘗試了這些設置,FillRate稍微下降到了3.5左右。任何其他想法? – oms
這並沒有完全解決問題,但確實有幫助。我實際上刪除了所有動畫並設置背景靜態。感謝指針。 – oms