Placing controls on datagrid with WPF - c#

I need a custom control element. I prototyped it and here it is on the picture. I think it is pretty self-explanatory. Could anyone suggest me how to organize it? I am not a WPF guru so if it will be working solution I'll better use it instead of doing by myself.
Sadly I can't post image, so it is here: http://imageshack.us/photo/my-images/521/control1.png/
Should I use datagrid with custom templates?
If so my question is how to populate row cells with custom contols and how to handle events on this controls to operate the RowId number?
How to apply custom templates for any individual cells? I found articles where templates applyed only for entire grid or column.
If anyone can help with this I would really appreciate it :)

I would suggest you to use ListView in grouping mode (with styles and templates)to accomplish this. Here are few samples doing similar to what you want to achieve -
ListView with grouping (In GridView mode)
Empty groups in WPF ListView
MSDN is also having one sample for this -
ListView Grouping Sample

I would personally use a TreeView. If your classes are already grouped properly ,you can then use HierarchicalDataTemplates to define how the TreeView works with each type. This will involve templates and triggers. Really, this will be mostly xaml, with very little event coding.

Related

Extended ListView control with a filter boxes on the column headers

I'm searching for extended ListView control with a filter boxes on the column headers - something like:
The image above is from DataGridExtensions WPF control, but I need a control for WinForms.
It will be excellent to have a control based on ListView, but any other help is appreciated (DataGrid-based control for example).
Thank you in advance.
You can either do it on your own by setting the ListView property OwnerDrawn.
Handle the DrawListViewColumnHeaderEventHandler and add your controls there. Then handle the changes and replace the ListView content by the filtered data. Or replace your backing data and refresh the control when you use VirtualMode.
If you want to use an existing, free control, I recommend to check on CodeProject. E.g.:
A simple one:ListViewFilter Control for .NET
And a really sophisticated one: A Much Easier to Use ListView
DataGridView-AutoFilter is a ready-made Nuget package, you just need to download it and follow this article, it is an easy and enhanced approach. DataGridView-AutoFilter demo example.

creating ListBoxItems with custom style in wpf

This may seem familiar to you but I have a problem creating a custom List Box with custom style as well. I can only do one of them at the same time... I can't use both. and another thing is that could you tell me how to add the custom listboxitem in c# code so I could easily add it to the program?
what I mean is that for example if you put an image before the text of listboxitem and then give it an style, but all thease must be done for all items.
thanks to all
First, what have you already tried out? Are you expecting SO users do the work for you?
Listbox tag has a ListboxItemTemplate. For that you can implement a DataTemplate has a StaticResource and put whatever you want inside.
Check the documentation on MSDN.
https://msdn.microsoft.com/en-us/library/system.windows.controls.itemscontrol.itemtemplate(v=vs.110).aspx

WPF window that looks like excel

I am new to WPF and c#, and I am trying trying to create an excel like table with a fixed number of columns and a varying number of rows according to the user's needs.People advise to use a datagrid, but I am very confused, some say that it is used mostly to display data source content (which is data contained in database if I understood). I read also about listviews, binding things to itemsource...etc. This is really a lot of information to work with! What I simply need is a way to create a table with fixed columns, and adding rows automatically when the user clicks on a button, that's it! No binding, or anything of this sort.But how to achieve that? Also, if you have good websites tutorials for working with datagrids, I would be very grateful (most of those that I found are too much complex, or don't explain well).
Thanks a lot!
You can create datatemplates that will style your data to look however you like - in this case an Excel row. Then you can display this data as the ItemsSource in an items control. Since you want the number of rows to vary based on some criteria, your data should be in an ObservableCollection. I'm not sure how you'd set-up the header, but I think you could style-up some containers and bind their width properties to the datatemplate controls.
If you wish to do more cell level customizations, then you can try Grid
http://www.syncfusion.com/products/user-interface-edition/wpf/grid/grid-control

TreeView with columns

I need a multi columned Treeview for an app I am writing, I was wondering if anyone knew of a free working (in Vs-2010) multi columned Treeview.
There are a number of sample controls to be found around the web:
TreeViewAdv for .Net
TreeView with Columns
ContainerListView and TreeListView
But the all-time favorite is probably the ObjectListView, which provides an expandable, multi-column ListView, along with many other incredibly handy features:
You can use this example here or download this control
Try this Microsof TreeListView WPF control
http://msdn.microsoft.com/en-us/library/vstudio/ms771523%28v=vs.90%29.aspx
You can do an illusion to the user in the user interface.
Drag a listview and drop this over the treeview which was already placed in the form.
Create columns in the listview as you need.
Set the 'HeaderStyle' property to 'Nonclickable' and 'Scrollabe' property to 'False' of the listview.
Set width and location of the listview as it fits to the treeview.

Insert a splitter (or expander) inside a gridview

I'm using Silverlight 4's gridview in my page, and I would like to have collapsible columns (to hide some rarely needed information). I had a look to DataGridTemplateColumn but it doesn't seem to allow me to do that. Googleing on this problem didn't help me either. (the only information I found is to set the visibility and/or the width of the columns in the code, but thatdoesn't solve my problem of inserting the splitter/expander).
Is there a way to do that ?
Thanks in advance !
Haver you had a look at the silverlight toolkit yet? They have a nice expander in the online demo that may do what you're looking for.

Categories