0

Windows モバイル アプリケーションに遷移効果を持たせたいのですが、Silverlight ツールキットの遷移効果を使用して実現できました。しかし問題は、すべての XAML ページで正確なコードを複製してしまったことです。

MainPage.xaml の抜粋と、ページの下部にある反復的なツールキット コードを提供しました。これを最適化する方法はありますか (1 つの場所に置いて使用します)。

Ruby on Rails では、そのコードのパーシャルを作成するだけでした。ここに似たようなものはありますか?

<phone:PhoneApplicationPage
    xmlns:toolkit="xyz"
    xmlns="xmlnamespace_value">

    <!-- PAGE DESIGN START -->
    ...
    ...
    ...
    ...
    <!-- PAGE DESIGN END -->

    <!-- REPEATING CODE START -->
    <toolkit:TransitionService.NavigationInTransition>
        <toolkit:NavigationInTransition>
            <toolkit:NavigationInTransition.Backward>
                <toolkit:TurnstileTransition Mode="BackwardIn"/>
            </toolkit:NavigationInTransition.Backward>
            <toolkit:NavigationInTransition.Forward>
                <toolkit:TurnstileTransition Mode="ForwardIn"/>
            </toolkit:NavigationInTransition.Forward>
        </toolkit:NavigationInTransition>
    </toolkit:TransitionService.NavigationInTransition>
    <!-- REPEATING CODE END -->
</phone:PhoneApplicationPage>
4

2 に答える 2

1

UserControl多分あなたは繰り返しコードを?に分けることができます

于 2012-07-05T08:48:51.290 に答える
1

スタイルを使用してページの効果を設定します。

アップデート:

  1. Styles.xaml:

    <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
        <Style x:Key="MyPageStyle" TargetType="Page">
            <Setter Property="Effect">
                <Setter.Value>
                    <DropShadowEffect />
                </Setter.Value>
            </Setter>
            <Setter Property="Background" Value="AliceBlue" />
        </Style>
    </ResourceDictionary>
    
  2. App.xaml

    <Application x:Class="WpfBrowserApplication1.App"
                 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                 StartupUri="Page1.xaml">
        <Application.Resources>
            <ResourceDictionary Source="Styles.xaml" />
        </Application.Resources>
    </Application>
    
  3. Page1.xaml

    <Page x:Class="WpfBrowserApplication1.Page1"
          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"
          Title="Page1"
          d:DesignHeight="300"
          d:DesignWidth="300"
          Style="{StaticResource MyPageStyle}" // Take a look at this line
          mc:Ignorable="d">
        <Grid />
    </Page>
    
于 2012-07-05T08:52:08.420 に答える