Visifire Forums: More DataBinding - Visifire Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

More DataBinding

#1 User is offline   chief7 Icon

  • Member
  • PipPip
  • Group: Members
  • Posts: 16
  • Joined: 01-May 08

Posted 25 July 2010 - 07:51 PM

I would like to see more databinding. As far as I can tell, the only databinding supported is on datapoints. I would like to see dataseries databinding and more databindable attributes (AxisMinimum for example).
0

#2 User is offline   vivek Icon

  • Advanced Member
  • PipPipPip
  • Group: Team Visifire
  • Posts: 2,539
  • Joined: 19-March 08
  • Gender:Male
  • Location:Bangalore

Posted 26 July 2010 - 04:50 AM

Hi Chief,

DataBinding using DataMapping is available for DataPoint properties only. But you can do property binding to any property of any chart element. Please refer the documentation here for more info.
Regards,
Vivek
Team Visifire
0

#3 User is offline   chief7 Icon

  • Member
  • PipPip
  • Group: Members
  • Posts: 16
  • Joined: 01-May 08

Posted 27 July 2010 - 02:00 AM

Should AxisMinimum be bindable? I can't seem to get to work.
0

#4 User is offline   vivek Icon

  • Advanced Member
  • PipPipPip
  • Group: Team Visifire
  • Posts: 2,539
  • Joined: 19-March 08
  • Gender:Male
  • Location:Bangalore

Posted 27 July 2010 - 04:31 AM

Hi Chief,

Yes you can achieve this using property binding by following the documentation here. Can you please tell me which version of Visifire are you using?
Regards,
Vivek
Team Visifire
0

#5 User is offline   chief7 Icon

  • Member
  • PipPip
  • Group: Members
  • Posts: 16
  • Joined: 01-May 08

Posted 28 July 2010 - 02:35 AM

I'm using version 3.5.7.0 compiled for WP7.

I doubled checked and I can't get AxisMinimum to databind.

I am successfully databinding LegendText.
0

#6 User is offline   vivek Icon

  • Advanced Member
  • PipPipPip
  • Group: Team Visifire
  • Posts: 2,539
  • Joined: 19-March 08
  • Gender:Male
  • Location:Bangalore

Posted 28 July 2010 - 06:00 AM

Hi Chief,

I checked it with WP7, it is working fine here. Please checkout the code below:

Create a class which implements INotifyPropertyChanged interface.

 public class BindValues : INotifyPropertyChanged
    {
        public Double AxisMinimum
        {
            get
            {
                return _a_min;
            }
            set
            {
                _a_min = value;
                FirePropertyChanged("AxisMinimum");
            }
        }

        #region INotifyPropertyChanged Members

        public event PropertyChangedEventHandler PropertyChanged;

        public void FirePropertyChanged(String propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }

        #endregion

        private Double _a_min = 5;
    }


Now instantiate the above class and set binding for AxisMinimum property as shown below:

public partial class MainPage : PhoneApplicationPage
    {
        // Constructor
        public MainPage()
        {
            InitializeComponent();

            // Set Binding for AxisMinimum property
            Binding binding = new Binding();
            binding.Source = bindValues;
            binding.Path = new PropertyPath("AxisMinimum");
            MyChart.AxesY[0].SetBinding(Axis.AxisMinimumProperty, binding);

            // Attach TextChanged event with TextBox created in XAML
            AxisMinTextBox.TextChanged += new TextChangedEventHandler(AxisMinTextBox_TextChanged);
        }

        void AxisMinTextBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            // Set AxisMinimum property of BindValues class
            TextBox textBox = sender as TextBox;
            if(!String.IsNullOrEmpty(textBox.Text))
                bindValues.AxisMinimum = Convert.ToDouble(textBox.Text);
        }

        // Initialize BindValues class
        BindValues bindValues = new BindValues();
    }


After running the application, once you type a value in the TextBox (AxisMinTextBox) field, it will reflect in chart Axis.
Regards,
Vivek
Team Visifire
0

#7 User is offline   chief7 Icon

  • Member
  • PipPip
  • Group: Members
  • Posts: 16
  • Joined: 01-May 08

Posted 29 July 2010 - 01:33 AM

I'm using the MVVM Light framework

XAML:

                <vc:Chart Height="350" BorderThickness="0" Theme="Theme1" ScrollingEnabled="False" >
                    <vc:Chart.AxesX>
                        <vc:Axis Title="Time of Day (min)"  Interval="1" AxisMinimum="{Binding XAxisMinimum}"  /> 
                    </vc:Chart.AxesX>
                    <vc:Chart.AxesY>
                        <vc:Axis Title="Travel Time" AxisType="Primary" />
                    </vc:Chart.AxesY> ...


ViewModel:

    public class TrackViewModel : ViewModelBase, ITrackViewModel
    {
        public double XAxisMinimum {
            get { return 100; }
        }
    }


Am I doing something wrong?
0

#8 User is offline   vivek Icon

  • Advanced Member
  • PipPipPip
  • Group: Team Visifire
  • Posts: 2,539
  • Joined: 19-March 08
  • Gender:Male
  • Location:Bangalore

Posted 29 July 2010 - 07:12 AM

Hi Chief,

Please check whether you are setting the binding Source properly.
Regards,
Vivek
Team Visifire
0

#9 User is offline   jasonflord25 Icon

  • Newbie
  • Pip
  • Group: Members
  • Posts: 1
  • Joined: 29-July 10
  • Gender:Male
  • Location:California
  • Interests:Travel, cultures, food, business, fun!!

Posted 29 July 2010 - 09:27 PM

View Postvivek, on 27 July 2010 - 04:31 AM, said:

Hi Chief,

Yes you can achieve this using property binding by following the documentation here. Can you please tell me which version of Visifire are you using?




thanks for the link been wondering how to do this.
Jason
0

#10 User is offline   chief7 Icon

  • Member
  • PipPip
  • Group: Members
  • Posts: 16
  • Joined: 01-May 08

Posted 30 July 2010 - 01:51 AM

On what element? I don't see a Source property on the Axis element.
0

#11 User is offline   vivek Icon

  • Advanced Member
  • PipPipPip
  • Group: Team Visifire
  • Posts: 2,539
  • Joined: 19-March 08
  • Gender:Male
  • Location:Bangalore

Posted 30 July 2010 - 05:07 AM

Hi Chief,

You have to set the Source property for binding as shown in this example inside SetBinding() function.
Regards,
Vivek
Team Visifire
0

#12 User is offline   chief7 Icon

  • Member
  • PipPip
  • Group: Members
  • Posts: 16
  • Joined: 01-May 08

Posted 30 July 2010 - 05:09 PM

Like I said before, I'm using the MVVMLight framework and avoiding any code in the code behind. Is there any way to set the source via xaml?
0

#13 User is offline   sharmila Icon

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 46
  • Joined: 16-June 10

Posted 02 August 2010 - 07:37 AM

Hi Chief7,

Quote

Like I said before, I'm using the MVVMLight framework and avoiding any code in the code behind. Is there any way to set the source via xaml?

At present Visifire has some issue while Databinding to custom class through xaml. We will look into the issue. But there is a workaround to bind properties.

For Example:

<vc:Axis Title="Axis-Y" AxisMinimum="{Binding ElementName=textBox1, Path=Text}"/>


In code behind

void textBox1_TextChanged(object sender, TextChangedEventArgs e)
  {
    TextBox tb = sender as TextBox;
    MyChart.AxesY[0].AxisMinimum = Convert.ToDouble(tb.Text);
  }



Regards,
Sharmila
0

#14 User is offline   chief7 Icon

  • Member
  • PipPip
  • Group: Members
  • Posts: 16
  • Joined: 01-May 08

Posted 02 August 2010 - 03:54 PM

When do you suspect it will be resolved?
0

#15 User is offline   vivek Icon

  • Advanced Member
  • PipPipPip
  • Group: Team Visifire
  • Posts: 2,539
  • Joined: 19-March 08
  • Gender:Male
  • Location:Bangalore

Posted 03 August 2010 - 06:38 AM

Hi Chief,

We will look into the issue on priority and update you as soon as we come up with a solution.
Regards,
Vivek
Team Visifire
0

#16 User is offline   shoaib Icon

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 106
  • Joined: 20-May 10
  • Gender:Male
  • Location:Bangalore

Posted 16 August 2010 - 08:33 AM

Hi Chief,

We have fixed the property binding issue. Please check with the internal release build here and let us know your feedback. Also please make sure that you have set the binding Source properly.
0

#17 User is offline   chief7 Icon

  • Member
  • PipPip
  • Group: Members
  • Posts: 16
  • Joined: 01-May 08

Posted 26 August 2010 - 03:53 PM

That fixed my issue. Thanks!

I couldn't user your link though. I had to get the wp7 dll from the download page.
0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users