2012-07-26 59 views
1

在Windows Phone中,我可以輕鬆地選取文本塊。但是有沒有解決方案可以定義模板的項目列表,並將其綁定到項目列表。Windows Phone - 模板選框

感謝 Gokoulane拉維

+0

Windows Phone中,我可以很容易地框選一個文本塊。 – IloveIniesta 2013-04-18 03:10:46

+0

你能告訴我如何實現這一點 – IloveIniesta 2013-04-18 03:37:12

回答

0

你可以做到這一點。但是,您需要編寫自定義XAML來實現此功能。 Blend可以幫助你在這裏創建自定義動畫並作爲選取框運行。

2

雖然它不是一個WP風格。

  1. 添加故事板頁面資源:

    <phone:PhoneApplicationPage.Resources> 
        <Storyboard x:Name="Scroll" RepeatBehavior="Forever"> 
         <DoubleAnimation From="480" To="-480" Storyboard.TargetName="translate" Storyboard.TargetProperty="X" Duration="0:0:5" /> 
        </Storyboard> 
    </phone:PhoneApplicationPage.Resources> 
    
  2. 添加ScrollViewer中,添加的StackPanel內的TextBlock內:

     <ScrollViewer x:Name="LongScrollViewer" VerticalScrollBarVisibility="Disabled" HorizontalScrollBarVisibility="Hidden" Margin="0,212,0,339" IsEnabled="False" > 
          <StackPanel Margin="0" Height="58"> 
           <TextBlock x:Name="LongTextBlock" Text="Very long, real long, it's a long text." Margin="0" Style="{StaticResource PhoneTextLargeStyle}" VerticalAlignment="Top" 
            HorizontalAlignment="Center" TextAlignment="Center" TextTrimming="None" TextWrapping="NoWrap"> 
            <TextBlock.RenderTransform> 
             <TranslateTransform x:Name="translate" /> 
            </TextBlock.RenderTransform> 
           </TextBlock> 
          </StackPanel> 
         </ScrollViewer> 
    
  3. 在頁面的Loaded方法中,確保TextBlock的文本足夠長,以便sc滾動:

    Size size = new Size(double.PositiveInfinity, double.PositiveInfinity); 
        this.LongTextBlock.Measure(size); 
        size = this.LongTextBlock.DesiredSize; 
    
        if (size.Width > this.ActualWidth) 
        { 
         this.Scroll.Begin(); 
        }