设为首页 加入收藏

TOP

WPF数字滚动效果(三)
2019-09-17 18:57:37 】 浏览:124
Tags:WPF 数字 滚动 效果
isibility
= Visibility.Collapsed; } } } } } public RollingNumberCtrl() { InitializeComponent(); } #region INotifyPropertyChanged接口 public event PropertyChangedEventHandler PropertyChanged; protected void OnPropertyChanged(string name) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(name)); } } #endregion private void UserControl_Loaded(object sender, RoutedEventArgs e) { if (_firstLoaded) _firstLoaded = false; foreach (FrameworkElement element in stackPanel.Children) { element.Height = this.ItemHeight; element.Width = this.ItemHeight * 0.6; if (element is RollingNumberItemCtrl) { RollingNumberItemCtrl num = element as RollingNumberItemCtrl; num.FontWeight = this.FontWeight; } if (element is Border) { Border border = element as Border; TextBlock txt = border.Child as TextBlock; txt.FontSize = this.ItemHeight; txt.FontWeight = this.FontWeight; } } Text = NumStr; } } } View Code

RollingNumberCtrl.xaml代码:

<UserControl x:Class="SunCreate.Common.Controls.RollingNumberCtrl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             xmlns:local="clr-namespace:SunCreate.Common.Controls"
             d:DesignHeight="30" d:DesignWidth="300" Loaded="UserControl_Loaded">
    <Grid>
        <StackPanel x:Name="stackPanel" Orientation="Horizontal" >
            <local:RollingNumberItemCtrl Height="30" Width="18" Num="0" Visibility="Collapsed"></local:RollingNumberItemCtrl>
            <local:RollingNumberItemCtrl Height="30" Width="18" Num="0" Visibility="Collapsed"></local:RollingNumberItemCtrl>
            <local:RollingNumberItemCtrl Height="30" Width="18" Num="0" Visibility="Collapsed"></local:RollingNumberItemCtrl>
            <local:RollingNumberItemCtrl Height="30" Width="18" Num="0" Visibility="Collapsed"></local:RollingNumberItemCtrl>
            <local:RollingNumberItemCtrl Height="30" Width="18" Num="0" Visibility="Collapsed"></local:RollingNumberItemCtrl>
            <local:RollingNumberItemCtrl Height="30" Width="18" Num="0" Visibility="Collapsed"></local:RollingNumberItemCtrl>
            <local:RollingNumberItemCtrl Height="30" Width="18" Num="0" Visibility="Collapsed"></local:RollingNumberItemCtrl>
            <local:RollingNumberItemCtrl Height="30" Width="18" Num="0" Visibility="Collapsed"></local:RollingNumberItemCtrl>
            <local:RollingNumberItemCtrl Height="30" Width="18" Nu
首页 上一页 1 2 3 4 5 下一页 尾页 3/5/5
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇使用C# 操作存储过程,执行sql语.. 下一篇C# 错误:空对象不能转换为值类型

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目