Windows Phone では、テキストブロックを簡単にマーキーできました。しかし、テンプレートを定義してアイテムのリストにバインドできるアイテムのマーキー リストに対する解決策はありますか。
ありがとうゴコウラネ・ラヴィ
Windows Phone では、テキストブロックを簡単にマーキーできました。しかし、テンプレートを定義してアイテムのリストにバインドできるアイテムのマーキー リストに対する解決策はありますか。
ありがとうゴコウラネ・ラヴィ
WP風じゃないけど…
ストーリーボードをページ リソースに追加します。
<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>
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>
ページの Loaded メソッドで、TextBlock のテキストがスクロールするのに十分な長さであることを確認します。
Size size = new Size(double.PositiveInfinity, double.PositiveInfinity);
this.LongTextBlock.Measure(size);
size = this.LongTextBlock.DesiredSize;
if (size.Width > this.ActualWidth)
{
this.Scroll.Begin();
}
出来るよ。ただし、この機能を実現するには、カスタム XAML を記述する必要があります。Blend は、カスタム アニメーションを作成してマーキーとして実行するのに役立ちます。