2012-07-26 56 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(); 
        }