首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >BounceEase和silverlight 4 BarSeries

问BounceEase和silverlight 4 BarSeries
EN

Stack Overflow用户
提问于 2010-05-21 04:00:58
回答 1查看 1.2K关注 0票数 1

我正在尝试让一个条形图系列在绘画时“反弹”,我以为BounceEase TransitionEasingFunction会这样做,但线条只是淡入,我已经在下面发布了xaml和代码,有人知道我哪里出了问题吗,或者它比我更复杂,我是silverlight的新手

XAML

代码语言:javascript
复制
<Grid x:Name="LayoutRoot" Background="White">
    <chartingToolkit:Chart x:Name="MyChart">
        <chartingToolkit:BarSeries Title="Sales" ItemsSource="{Binding}" IndependentValuePath="Name" DependentValuePath="Value" AnimationSequence="FirstToLast" TransitionDuration="00:00:3">
            <chartingToolkit:BarSeries.TransitionEasingFunction>
                <BounceEase EasingMode="EaseInOut" Bounciness="5" />
            </chartingToolkit:BarSeries.TransitionEasingFunction>
            <chartingToolkit:BarSeries.DataPointStyle>
                <Style TargetType="Control">
                    <Setter Property="Background" Value="Red"/>
                </Style>
            </chartingToolkit:BarSeries.DataPointStyle>
        </chartingToolkit:BarSeries>
        <chartingToolkit:Chart.Axes>
            <chartingToolkit:LinearAxis Title="Types owned"  Orientation="X" Minimum="0" Maximum="300" 
              Interval="10" ShowGridLines="True"  FontStyle='Italic'/>
        </chartingToolkit:Chart.Axes>
    </chartingToolkit:Chart>

</Grid>

代码隐藏

代码语言:javascript
复制
public class MyClass : DependencyObject
    {
        public string Name { get; set; }
        public Double Value {
            get { return (Double)GetValue(myValueProperty); } 
            set{SetValue(myValueProperty,value);} 
        }
        public static readonly DependencyProperty myValueProperty =
            DependencyProperty.Register("Value", typeof(Double), typeof(MyClass), null);
    }

public MainPage()
        {
            InitializeComponent();
            //Get the data
            IList<MyClass> l = this.GetData();
            //Get a reference to the SL Chart

        MyChart.DataContext = l.OrderBy(e => e.Value);
        //Find the highest number and round it up to the next digit
        DispatcherTimer myDispatcherTimer = new DispatcherTimer();
        myDispatcherTimer.Interval = new TimeSpan(0, 0, 0, 5, 0); // 100 Milliseconds 
        myDispatcherTimer.Tick += new EventHandler(Each_Tick);
        myDispatcherTimer.Start();

    }
    public void Each_Tick(object o, EventArgs sender)
    {
        ((BarSeries)MyChart.Series[0]).DataContext = GetData();
    }

    private IList<MyClass> GetData()
    {
        Random random = new Random();

        return new List<MyClass>()
        {
            new MyClass() {Name="Bob Zero",Value=(random.NextDouble() * 100.0)},
             new MyClass() {Name="Bob One",Value=(random.NextDouble() * 100.0)},
              new MyClass() {Name="Bob Two",Value=(random.NextDouble() * 100.0)},
               new MyClass() {Name="Bob Three",Value=(random.NextDouble() * 100.0)}
        };
    }
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2010-05-21 05:46:15

名称BounceEase指的是要设置动画的值在动画时间内的变化方式。BounceEase会改变值,就像你想象的那样,就像一个球在弹跳一样。文档中的图表对此进行了描述。

关键的一点是,动画最终只是改变了一个值,他们并不真正理解改变值的视觉效果是什么。在这种情况下,要设置动画的值是DataPoint不透明度。因此,随着弹跳的轻松,它看起来会淡入一点,然后淡出,然后再淡出一点,以此类推,直到它完全淡入。

为DataPoint创建一个新的模板需要更多的工作才能得到你想要的效果。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/2877378

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档