I am trying to create some charts for a C# .NET 4.0 Winforms application. I have begun with the pie-Chart. Is there a way to use databinding in order to keep the chart updated?
So far I have only managed to use the DataPoint.YValues property to change the chart's appearance.
The Series object has got a DataSource property, but I am not sure how to use this DataSource for the single points (which are inside a list, inside the series property).
I hope I could explain my question detailed enough.
PS: The charts are from the System.Forms.DataVisualization.Charting namespace.
Related
I have a list of objects (same class). Each of these objects has couple of properties. I would like to build a GUI that would show a "tile" for each of these objects and in this "tile" the property values of this object would be displayed. The image bellow illustrates the idea.
By pressing on the + tile it would be possible to add new object (would bring up the dialogue). The object tiles would wrap to the next line allowing X tiles per line.
What would be your suggestions to do this in a civilized manner to be able to automatically add/remove tiles as an object in the list is created/deleted? Maybe someone knows some examples?
Currently I'm quite blank on how to achieve this.
Consider using some sort of ItemsControl with a DataTemplate. I would review the follow tutorial on how to do that: http://wpftutorial.net/DataTemplates.html
As Matt Burland stated, you will need to put your objects into a ObservableCollection for them to appear "dynamically".
1) Use a ListBox, bind ItemsSource property to your List.
2) Insert whatever kind of object you like in that list.
3) Create DataTemplate for each kind of object to display
Please refer to this post -
WPF toolkit for tile listview
it outlines using a ItemsControl with wrap panel create a tile effect.
Hope that helps.
I am using an Infragistics XamDataChart and want to bind a collection in my view model to the chart's Series property, since I don't know in advance how many line charts I will need to display.
From what I can gather from old posts in the Infragistics support forums, the Series property is read only and thus doesn't support binding directly. A solution is offered here but it seems like overkill for such a simple goal (maybe to me it just seems simple).
Has anyone here done any work with the Infragistics xamDataChart and MVVM? The ultimate goal is to be able to have a collection in my view model that contains a variable number of 'series' that I can just bind to the chart. Now I can probably do this if I just write some code behind for my xaml, access the DataContext (viewModel) and listen to the collection property, directly adding/removing series to the chart as necessary, but I was looking for a more MVVM way.
Thanks.
Since the Series collection of the XamDataChart is read-only, in order to be able to generate the Series dynamically,based on you VeiwModel, you should use helper class, similar to the approach that Graham Murray has suggested in the thead that you have referred. I have created a sample applicaiton, that show how you can create similar appraoch for binding the series of the XamDataChart to collection of your ViewModel. You can download the sample from here:
http://users.infragistics.com/Samples/SeriesBinder.zip
Sincerely,
Krasimir
Can I somehow use POCOs in a ListView? Or are ListViewItem's my only option?
If I can only use ListViewItems is it possible to assign a value object (my POCO) or is it possible to use subitems with value objects?
Thanks in advance!
You can use ObjectListView which plays very nicely with POCOs.
Update
ObjectListView is based on the regular ListView, but it uses some magic and the win32 api to make everything possible. It's not very hard to get started with it and I don't really see why you can't use it?
Standard listview: All options (except owner drawing) include using a ListViewItem. If you got a large collection I recommend that you use Virtual Mode which means that the list view will request each item that is visible.
I just found out the ListViewItem.ListViewSubItem class Tag and Text work fine for me. No Pocos though, but I can keep the original values in their original data types.
I'm trying to have a grid that has items that have a custom layout/feel. If you have a look at the following http://mdavey.files.wordpress.com/2007/05/ldmain.jpg this is kinda what I am trying to do (see the aqua/red pods on the left and the graphs on the bottom right).
Under WPF/ASP.Net I would know how to do this but in WinForms I have no idea (I have never had to work on a WinForms app before). Like in WPF I would use Data Templates.
Hence I was wondering anyone knows of any good resources that goes through this or if anyone knows if its just as easy as creating a custom control, they having a grid that has one column and setting the type of that column to the custom control and then binding the data source to the grid???
Cheers Anthony
You may check Essential Grid - it seems to me it supports features you need.
There is an example for progress bar cell which you could use for the graphs on the right side:
http://www.syncfusion.com/products/user-interface-edition/windows-forms/grid/progressbar-cell
And they have Push Button cell type which you could use for your pods on the left side:
http://www.syncfusion.com/products/user-interface-edition/windows-forms/grid/push-button
You might also check DevExpress XtrGrid:
http://www.devexpress.com/products/net/controls/winforms/grid/dataediting.xml
http://www.devexpress.com/products/net/controls/winforms/grid/appearance.xml
In any case, I would search for a component - it takes quite a lot of time to do such things from the scratch.
I'm very new to WPF, and am trying to set the datasource (which the WPF Grid doesn't have as a property) of my grid to take a List. Does anyone have any code examples of how to do this. I have googled it, but can't find any really good examples.
(Oh, and can anyone suggest a good site for all round WPF Code examples?)
Thanks
If you're referring to a WPF Grid, you can't bind it to data; it's meant for layout purposes only; you might want to look into one of the controls that inherit from ItemsControl, such as ListView.
The property you'd bind your list to, is called ItemsSource.
The other control you might be thinking of is the GridView
There's also the DataGrid (Note old link) in the WPF Toolkit which implements a lot of the same functionality as the WinForms DataGridView