zoukankan      html  css  js  c++  java
  • silverlight 滚动文字

    <Canvas x:Name="c1" >
                            <Canvas.Triggers>
                                <EventTrigger RoutedEvent="Canvas.Loaded">
                                    <BeginStoryboard>
                                        <Storyboard x:Name="animation" RepeatBehavior="Forever">
                                            <DoubleAnimation Storyboard.TargetName="tbnews" Storyboard.TargetProperty="(Canvas.Left)" From="100" To="-200"  Duration="0:0:20">
                                                
                                            </DoubleAnimation>
                                        </Storyboard>
                                    </BeginStoryboard>
                                </EventTrigger>
                            </Canvas.Triggers>
                            
                        <TextBlock x:Name="tbnews" Text="{Binding txtnews}" FontSize="14" HorizontalAlignment="Left" Foreground="Yellow" >
                        <TextBlock.Effect>
                              <DropShadowEffect Color="White"   
        BlurRadius="30" Opacity="1" ShadowDepth="0"/>                
                        </TextBlock.Effect>
                        </TextBlock>
                        </Canvas>
                        <TextBlock Text="{Binding addtime}"  HorizontalAlignment="Left" FontSize="10" Foreground="Yellow">
                             <TextBlock.Effect>
                              <DropShadowEffect Color="White"   
        BlurRadius="30" Opacity="1" ShadowDepth="0"/>                
                        </TextBlock.Effect>    
                        </TextBlock>

    第二种方法

     <ListBox.ItemTemplate>
                                        <DataTemplate>

                                            <Grid x:Name="LayoutNews" >
                                                <Grid.Clip>
                                                    <RectangleGeometry x:Name="rg" Rect="0,150,100,100" />
                                                </Grid.Clip>
                                                <Canvas Width="150" x:Name="canvasNews" Background="White">
                                                    <StackPanel>
                                                        <TextBlock x:Name="tb" Margin="0,5,0,0" TextWrapping="Wrap" Width="150" Text="{Binding txtnews}" Foreground="Yellow">
                             <TextBlock.Effect>
                              <DropShadowEffect Color="White"   
        BlurRadius="30" Opacity="1" ShadowDepth="0"/>                
                        </TextBlock.Effect>
                                                        </TextBlock>
                                                        <TextBlock Text="{Binding addtime}"  HorizontalAlignment="Left" FontSize="10" Foreground="Yellow">
                             <TextBlock.Effect>
                              <DropShadowEffect Color="White"   
        BlurRadius="30" Opacity="1" ShadowDepth="0"/>                
                        </TextBlock.Effect>
                                                        </TextBlock>
                                                    </StackPanel>
                                                </Canvas>

                                                <Rectangle Width="300" Height="1" Fill="#3E2A0C"></Rectangle>

                                            </Grid>

                                        </DataTemplate>
                                    </ListBox.ItemTemplate>

     int top = 0;
            public MainPage()
            {
                // 为初始化变量所必需
                InitializeComponent();
                AddItems();
                displaynews();
                DispatcherTimer dt = new DispatcherTimer();
                dt.Interval = new TimeSpan(0, 0, 0, 0, 100);
                dt.Tick += new EventHandler(dt_Tick);
                dt.Start();
            }
            void dt_Tick(object sender, EventArgs e)
            {
                top = top - 10;
                Canvas canvasNews = LayoutNews.FindName("canvasNews") as Canvas;
                
                canvasNews.Margin = new Thickness(0, top, 0, 0);

            }

    如果本文引用了你的文章而未注明,请及时联系我。
  • 相关阅读:
    面对诱惑我们应有的态度
    TED 停止寻找你的热情
    C字符数组的处理
    对Linux(Unix)的基础知识归纳
    对Hadoop体系的一点认识
    Android开发涉及有点概念&相关知识点(待写)
    IOS开发涉及有点概念&相关知识点
    对CLR基本原理概念&垃圾回收机制的简单理解
    含有指针变量的类需要重写拷贝构造函数,拷贝赋值函数,析构函数
    malloc分配内存的结构
  • 原文地址:https://www.cnblogs.com/sunxi/p/2714271.html
Copyright © 2011-2022 走看看