2013-10-09 57 views
1

我想在Windows Phone 8中創建一個試用應用程序,並且我希望允許用戶選擇是否購買應用程序或不按鈕事件。我的想法是,經過這麼多的啓動後,MainPage會在其上面進行某種調光或覆蓋,因此用戶可能不會與應用程序進行交互,並且消息和按鈕會出現在頂部,最終詢問用戶是否需要購買應用程序或不。是否有可能做這樣的事情?我不確定實際創建全新頁面是否會更好,但我的想法是,如果用戶可以看到變暗疊加層背後的功能,那麼他們會更有興趣繼續購買並返回到這些功能。我該如何做這樣的事情?如何將整個屏幕變暗並在中心放置一個按鈕

編輯

也許適應這樣的事情http://developer.nokia.com/Community/Wiki/Create_simple_overlay_with_UserControl_in_Windows_Phone

回答

0

這應該是相當簡單的 - 首先添加一個像邊框這樣的疊加層和默認隱藏的「購買」按鈕。只要確保覆蓋是根的最後一個孩子,所以它總是會出現在最前面:

<Grid x:Name="LayoutRoot"> 

    <!-- Main content here --> 

    <Border x:Name="overlay" RowSpan="10" ColumnSpan="10" 
     Opacity="0.5" Background="#666" 
     Visibility="Collapsed" /> 
    <Button x:Name="btnPurchase" 
     Content="Purchase" 
     HorizontalAlignment="Center" VerticalAlignment="Center" 
     Command="{Binding StartPurchaseCommand}" 
     Visibility="Collapsed" /> 
</Grid> 

現在添加了「購買」可視狀態來顯示覆蓋+按鈕:

<Grid x:Name="LayoutRoot"> 

    <VisualStateManager.VisualStateGroups> 
     <VisualStateGroup x:Name="PurchaseStates"> 
      <VisualState x:Name="TrialState" /> 
      <VisualState x:Name="PurchaseRequired"> 
       <Storyboard> 
        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="overlay" Storyboard.TargetProperty="Visibility"> 
         <DiscreteObjectKeyFrame> 
          <DiscreteObjectKeyFrame.Value> 
           <Visibility>Visible</Visibility> 
          </DiscreteObjectKeyFrame.Value> 
         </DiscreteObjectKeyFrame> 
        <ObjectAnimationUsingKeyFrames> 
        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="btnPurchase" Storyboard.TargetProperty="Visibility"> 
         <DiscreteObjectKeyFrame> 
          <DiscreteObjectKeyFrame.Value> 
           <Visibility>Visible</Visibility> 
          </DiscreteObjectKeyFrame.Value> 
         </DiscreteObjectKeyFrame> 
        <ObjectAnimationUsingKeyFrames> 
       </Storyboard> 
      </VisualState> 
     </VisualStateGroup> 
    </VisualStateManager.VisualStateGroups> 

然後,只要試用期結束,只需在啓動時調用VisualStateManager.GoToState(this, "PurchaseRequired", true)即可。

+0

謝謝。我嘗試在我的OnNavigatedTo事件中添加VisualStateManager.GoToState(this,「PurchaseRequired」,true);以查看會發生什麼,但是我得到一個'InvalidOperationException'。我計劃在15天之後說出類似的內容。你會爲此推薦什麼? – Matthew

+0

@Matthew我不確定交易是什麼 - 如果狀態是在頁面的根元素下定義的,那麼這個工作應該可行。也許通過綁定到VM屬性來設置可見性會更容易。 – McGarnagle

+0

嗯,我不確定。在Windows Phone 8中使用'Popup'控件怎麼樣?有沒有辦法顯示彈出窗口並將屏幕的其餘部分調暗並阻止用戶界面進行任何用戶交互? – Matthew

相關問題