2011-10-17 58 views
2

我目前正在Silverlight 4中的Kiosk應用程序中工作。用戶可以將項目添加到購物車並使用Kiosk檢出所有項目。當從一個頁面到另一個頁面時,我想要合併一個閃爍的「外部輝光」的按鈕,如果您願意的話,在按鈕的背景上以及按鈕的文本中。我可以用圖像做到這一點,但文本需要動態,我希望能夠創建這個模板作爲模板以後在其他按鈕上調用。Silverlight 4中的TextBlock.Text閃爍按鈕

我想開始時只是想讓文本在我的按鈕內閃爍。

  <Button Name="AddItemButton" Height="110" Click="AddItemButton_Click" Visibility="Collapsed" 
         Grid.Row="4" VerticalAlignment="Top" Style="{StaticResource ButtonRound1}"> 
       <Button.Resources> 
        <Storyboard x:Name="FlashMe"> 
         <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="AddItemButtonTextBlock"> 
          <EasingDoubleKeyFrame KeyTime="0:0:1" Value="0"/> 
          <EasingDoubleKeyFrame KeyTime="0:0:2" Value="1"/> 
         </DoubleAnimationUsingKeyFrames> 
        </Storyboard> 
       </Button.Resources> 
       <Grid> 
        <Image Source="Images/bg-greengradient.png" Stretch="Fill"/> 
        <TextBlock x:Name="AddItemButtonTextBlock" Text="Add Item" HorizontalAlignment="Center" VerticalAlignment="Center"/> 
       </Grid> 

      </Button> 

正如你所看到的,我的Button.Content是一個包含2個項目的網格。我有一個圖像和一個TextBlock。 TextBlock應該由我的FlashMe storyboard控制,但是在後面的代碼中,我嘗試使用FlashMe.Begin()時出錯。這幾乎就像我不允許在按鈕的內容上使用故事板。有任何想法嗎?

任何幫助,非常感謝,謝謝。

+0

你會得到什麼錯誤?特別? – Nate

+0

刪除了FlashMe.Begin()後面的codeb;但仍然收到錯誤System.ArgumentException:值不在預期範圍內。 – PatTheDeveloper

+0

如果它只是上面的代碼沒有任何代碼後面應該工作正常,錯誤必須來自別的東西。 –

回答