Example #1
0
        /// <summary>
        /// Gets a data bound Graph Point element.
        /// </summary>
        /// <param name="o">Object containing binding data.</param>
        /// <returns>GraphPoint with bound data.</returns>
        internal GraphPoint GetBoundGraphPoint(object o)
        {
#if SILVERLIGHT
            DependencyObject dp = this.PointTemplate.LoadContent();
            if (null == dp)
            {
                return null;
            }

            GraphPoint gp = dp as GraphPoint;
            if (null == gp)
            {
                return null;
            }

            gp.DataContext = o;
#else
            GraphPoint gp = new GraphPoint();
            if (null == this.bindingY1 && null == this.bindingY2 && null == this.bindingX2)
            {
                return null;
            }

            if (null != this.bindingY1)
            {
                Binding b1 = new Binding();
                b1.Mode = BindingMode.OneTime;
                b1.Path = this.bindingY1.ParentBinding.Path;
                b1.Source = o;
                gp.SetBinding(GraphPoint.Y1Property, b1);
            }

            if (null != this.bindingY2)
            {
                Binding b2 = new Binding();
                b2.Mode = BindingMode.OneTime;
                b2.Path = this.bindingY2.ParentBinding.Path;
                b2.Source = o;
                gp.SetBinding(GraphPoint.Y2Property, b2);
            }

            if (null != this.bindingX1)
            {
                Binding b3 = new Binding();
                b3.Mode = BindingMode.OneTime;
                b3.Path = this.bindingX1.ParentBinding.Path;
                b3.Source = o;
                gp.SetBinding(GraphPoint.X1Property, b3);
            }

            if (null != this.bindingX2)
            {
                Binding b4 = new Binding();
                b4.Mode = BindingMode.OneTime;
                b4.Path = this.bindingX2.ParentBinding.Path;
                b4.Source = o;
                gp.SetBinding(GraphPoint.X2Property, b4);
            }

            if (null != this.bindingDataMarkerTemplate)
            {
                Binding b5 = new Binding();
                b5.Mode = BindingMode.OneTime;
                b5.Path = this.bindingDataMarkerTemplate.ParentBinding.Path;
                b5.Source = o;
                gp.SetBinding(GraphPoint.DataMarkerTemplateProperty, b5);
            }

            if (null != this.bindingLabel)
            {
                Binding b6 = new Binding();
                b6.Mode = BindingMode.OneTime;
                b6.Path = this.bindingLabel.ParentBinding.Path;
                b6.Source = o;
                gp.SetBinding(GraphPoint.LabelProperty, b6);
            }

            gp.DataContext = o;
#endif

            return gp;
        }