WPF ColorGrid DataBinding
WPF ColorGrid DataBinding
Hi,
Are there any examples showing how to use a WPF ColorGrid that has a databinding defined in xaml?
Thanks
Are there any examples showing how to use a WPF ColorGrid that has a databinding defined in xaml?
Thanks
-
- Guru
- Posts: 1603
- Joined: Fri Nov 15, 2002 12:00 am
Re: WPF ColorGrid DataBinding
Hello,
Not at the moment I'm afraid, no - I've added this request to our issue tracker with id=2412, meaning an implementation of it will become available shortly.
Best Regards,
Christopher Ireland / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
-
- Guru
- Posts: 1603
- Joined: Fri Nov 15, 2002 12:00 am
Re: WPF ColorGrid DataBinding
Hello,
just to let you know we've released a new NuGet in which the ColorGrid series is present in the TeeChart.Xaml.WPF assembly - you can see an example of it working in this example:
just to let you know we've released a new NuGet in which the ColorGrid series is present in the TeeChart.Xaml.WPF assembly - you can see an example of it working in this example:
Best Regards,
Christopher Ireland / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Re: WPF ColorGrid DataBinding
How do I databind x,y,z that is used in the ColorGrid to a viewmodel?
-
- Guru
- Posts: 1603
- Joined: Fri Nov 15, 2002 12:00 am
Re: WPF ColorGrid DataBinding
There are a couple of Binding examples already in the examples, specifically those in this example here: You should be able to adapt these techniques to the ColorGrid - any problems do please let us know.
Best Regards,
Christopher Ireland / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Re: WPF ColorGrid DataBinding
I did not see an example for binding 3D data (x,y,z).
-
- Guru
- Posts: 1603
- Joined: Fri Nov 15, 2002 12:00 am
Re: WPF ColorGrid DataBinding
As I say, I think you will be able to adapt the 2D (x,y) data techniques shown in those examples to the 3D (x,y,z) data of the ColorGrid.
Best Regards,
Christopher Ireland / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Re: WPF ColorGrid DataBinding
Do I use Series3DData and do I setup the binding on X, Y, Z as shown
series:Series3DData X="{Binding XData}" Y="{Binding YData}" Z="{Binding ZData}"
When I do this I get a binding error during runtime.
series:Series3DData X="{Binding XData}" Y="{Binding YData}" Z="{Binding ZData}"
When I do this I get a binding error during runtime.
-
- Guru
- Posts: 1603
- Joined: Fri Nov 15, 2002 12:00 am
Re: WPF ColorGrid DataBinding
Which of the two examples are you trying to follow, BindingDataProperties.xaml or BindingObservableCollection.xaml?
Best Regards,
Christopher Ireland / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Re: WPF ColorGrid DataBinding
BindingObservableCollection.xaml
Re: WPF ColorGrid DataBinding
I tried the following but did not get a ColorGrid plot. It looked more like a (x,y) scattered plot. I think the problem is associated with not setting IrregularGrid to false. I do not see how to do this since colorgrid is a series and not Steema.TeeChart.WPF.Styles.
and in my ViewModel I have
Code: Select all
<Grid>
<teechart:TChart x:Name="tchart">
<series:ColorGrid x:Name="colorgrid" UsePalette="True" UseColorRange="False" PaletteStyle="Rainbow" ItemsSource="{Binding DataArray}" XPath="X" YPath="Z" ZPath="Y" />
</teechart:TChart>
</Grid>
Code: Select all
public ObservableCollection<Data> DataArray { get; private set;}
public class Data
{
public double X;
public double Y;
public double Z;
public override string ToString()
{
return $"({X:F4}, {Y:F4}, {Z:F2})";
}
}
-
- Guru
- Posts: 1603
- Joined: Fri Nov 15, 2002 12:00 am
Re: WPF ColorGrid DataBinding
Best Regards,
Christopher Ireland / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Re: WPF ColorGrid DataBinding
Hello,
I changed your BindingDataPropertiesViewModel constructor slightly to show a problem I am seeing. I expect to see a ColorGrid where both axis range from (-1 to 1). Instead I see something that is partially displayed in the upper right half. In this example dx=0.2 and dz=0.1. Therefore, the axis ideally should be x=-1,-0.8,-0.6,...,0.8,1.0 and z=-1,-0.9,-0.8,..., 0.9, 1.0. However, due to numerical precision, the axis appears to be irregular which is causing problems for ColorGrid.
I changed your BindingDataPropertiesViewModel constructor slightly to show a problem I am seeing. I expect to see a ColorGrid where both axis range from (-1 to 1). Instead I see something that is partially displayed in the upper right half. In this example dx=0.2 and dz=0.1. Therefore, the axis ideally should be x=-1,-0.8,-0.6,...,0.8,1.0 and z=-1,-0.9,-0.8,..., 0.9, 1.0. However, due to numerical precision, the axis appears to be irregular which is causing problems for ColorGrid.
Code: Select all
public BindingDataPropertiesViewModel()
{
int nx = 11;
int nz = 21;
double dx = 2.0 / (double)(nx - 1);
double dz = 2.0 / (double)(nz - 1);
Data = new Series3DData[nx*nz];
int k = 0;
for (int i = 0; i < nx; i++)
{
double x = -1.0 + i * dx;
for (int j = 0; j < nz; j++)
{
double z = -1.0 + j * dz;
Data[k] = new Series3DData { X = x, Y = Math.Sin(k / (double)(nx * nz) * Math.PI * 2) * Height, Z = z };
k++;
}
}
//_timer = new DispatcherTimer(DispatcherPriority.Normal) { Interval = TimeSpan.FromSeconds(0.05) };
//_timer.Tick += OnTick;
//_timer.Start();
}
-
- Guru
- Posts: 1603
- Joined: Fri Nov 15, 2002 12:00 am
Re: WPF ColorGrid DataBinding
Hello,
Does this code work for you at runtime, that is, without use of the TeeChart.Xaml.WPF assembly?
Best Regards,
Christopher Ireland / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Re: WPF ColorGrid DataBinding
Hi Christopher,
I am not sure I understand your question. Are you asking if the code snippet I supplied for a change in the constructor compiles and runs?
Yes, I was able to compile and run the changes in the example project that you created.
I am not sure I understand your question. Are you asking if the code snippet I supplied for a change in the constructor compiles and runs?
Yes, I was able to compile and run the changes in the example project that you created.