TreeView with Customized Style WPF - c#

I have a requirement in that i need to display items of treeview in a below specified pattern. Here i have a treeview with three levels. I need custom style for all three levels. Could you please help me...

You can create a custom style for TreeViewItems and TreeView, this would give you the ability to design your own UI for the control.
The link below shows what controls you would need to style.
https://msdn.microsoft.com/en-us/library/ms752048(v=vs.110).aspx

From the image you posted, it looks pretty straight forward. You can just have your own HierarchicalDataTemplate and DataTemplate for your nodes. Take a look at example here.
However if you want a great control on node's layout and behaviour then creating a custom ControlTemplate for the TreeViewItem is your best bet. There are many nice articles over internet. May be you can follow this one here.

Related

WPF: How to dynamically create controls and edit controls in code

I have a xaml which contains a tab control (Name="MyTabControl"). I'm a beginner with wpf and in code and I want to dynamically add tab items that I then add a list box to each created tab item. Below is the code I have so far.
ListBox listbox = new ListBox()
TabItem tab = new TabItem()
tab.AddChild(listbox)
MyTabControl.Add(tab)
My issue is that I can't figure out how dynamically create new tabs that also would add a list box to each new tab and the new tabs then added to MyTabControl.
Then, I would want to be able to access each list box control, individually, in each tab to edit the list box content.
How is this done in code? How can i access the created list box controls to edit them?
WPF/UWP and XAML are designed with the MVVM pattern in mind. While you can use other approaches, doing so will miss about 90% of it's power and run into issues at every other corner.
In MVVM this would be simply a mater of Exposing a Collection and having a Tempalte targetting that type. ListBoxes might even have a custom Template system, but using ListBoxes might no longer be nessesary - any container can expose a Collection.
If you plan on learning MVVM, mid to longertem you should learn MVVM. I wrote a short intro a few years back, that should help you going. Help for people not following MVVM is parse on the Forum.
In general, it's a violation of the MVVM principles WPF is built around to build a UI in this way. Instead, consider a solution similar to the one proposed in the answers to this question. They do a good job of explaining both what to do, and why we do it this way.

WPF treeview needed without indentation

I am very new to WPF and developing first form in WPF as I have some specific design and feature requirement in tree-view.
I need to develop a treeview where only root nodes should be indented as default while their treeviewitems should be start from same 0 position, no indentation needed.
Please refer below image for reference -
Kindly help me to get it done by sharing any solution.
Either use Grouping with datagrid it will give somewhat following output:
Or can use RadTreeListView like control. More details can be found here.
As per comment if you have to use the treeview only then you have to override the templates. You can refer the following post:
Decrease indentation in TreeViewItem for deepest node
WPF Tree view, how to change indention

WPF Control Identification

Sorry but I am a newbie to WPF, I would really appreciate if you could help me-
Tag 1 in pic- Which control can I use to create a menu similar to that in the picture ? The closest I came was using a gridview within a listview but that ends up using a header for the gridview. Normal listview just highlights the entire strip and doesn't look good at all.
Tag 2 in pic // (No longer relevant, sorry)
Edit:
Looking for something simple like when using gridview with listview (as in pic below) there is automatically that standard window gradient & bevel effect etc. (As an idea, implementing it with buttons seems to cumbersome, first strip button border, then create all these effects.) So essentially anything already inbuilt in WPF.
Thanks for any help :-D !!!
ListBox or ListView are good controls to use. If it's just the 'pretty' factor you don't like, you can provide Templates to change the appearance. But functionally, ListBox and ListView provide the function of that menu.
When working with WPF, that should be your primary motivation when choose controls. What FUNCTIONS the way you want. You can always make it LOOK different with Templates, but getting the right FUNCTION is the primary goal for the control.

WPF: Strategy for Creating a Single Item Paged ItemsControl

I am wanting to build a WPF custom control that displays validation errors - one at a time - in a ribbon that goes across the top of the screen.
An ItemsControl or Selector sounds like a potential base class candidate, but my requirement is that only one item is shown at a time and the user will click on forward and back buttons on the ribbon to navigate through the validation errors.
Is it possible to use an ItemsControl in this way? To only show one item at a time?
Is there a better strategy for this?
I appreciate your thoughts and expertise!
This article should cover everything you want to do. The FlipView basically behaves like an ItemsControl and shows one item at a time by providing forward/back buttons.

ListView with TreeViewItems in xaml

I'm pretty new to c#, the first thing that I'm trying to make is a ListView with data bindings which has turned out ok.
I'm now trying to make items have a twist button if the underlying model has any children (like the TreeView). Each of the children will have columns the same as all the top level items.
How would I go about doing this? Is there an already existing control like this? If not would I be better off dressing up a TreeView to look like a ListView, or dress up a ListView to look like a TreeView?
I went down the road outlined in this solution which dresses up a TreeView, but the end result looks pretty awful and the heading is actually just an item, so you lose all the nice column sizing and column buttons that can hook up to column sorting that you get in ListView so that route actually seems like it would be more work.
I noticed the new task manager has a control exactly like what I'm trying to create, I don't know how this made? probably in C though.
Microsoft provides a sample that appears to be what you are looking for. A write-up of the example can be found here:
http://msdn.microsoft.com/en-us/library/vstudio/ms771523(v=vs.90).aspx
When you build and run the example you will end up with something resembling this:
There is a large amount of templating done in the example, so you will be able to make things look the way you want.
What you describe sounds a bit like a TreeListView, and if you google 'WPF TreeListView' you will see some solutions that might be good for you. I have used one from Telerik, but it might be overkill depending on how complicated your needs are.
If you only want one sub-level like the image you attached, you might want to just roll your own using a ListView with a complex DataTemplate for the first column which would show an expander button and a simple ListBox bound to the children items.
Similar to the answer here, except your cell would have a checkbox styled to look like the arrow, the text for the item, and a child ListBox. Then bind the visibility of the child ListBox to the state of the checkbox.

Categories

Resources