Tree View of a Data Grid - c#

I am trying to implement some tree like that in ASP.NET: alt text http://i.msdn.microsoft.com/w6ws38fw.vbVenusSiteNavigation_TreeView1(en-us,VS.100).gif
However, this is a TreeView component in the Navigation Tab. I want a DataGrid in a tree view which isn't navigation. Is there a ready FREE component out there?? If not, what is the right component to start with to build such a tree component???
I'm not in a hurry, it will be better for me if I can build my own, but I want to know the component to start with?is it the DataGrid?

Don't get hung up on the fact that it appears in the Navigation tab in the Toolbox - there's nothing to stop you using the <asp:treeview> to represent another hierarchical structure. Have a look at the Treeview Quickstart tutorial which covers using it for data as well as navigation.

Related

AVL tree visualization c#

I have a school project to implement an AVL Tree and to do some kind of UI application to show how it works. I haven't done the code of the implementation yet, but that is not the trouble. I have no idea how to visualize my implementation. I want to do something like this: http://visualgo.net/bst.html# . Could somebody give me some directions about?
There are many options. I'll give you a few sulutions that seems to be easy to implement:
Write a simple WinForms applications with only one window. This window should contain only one control i.e. TreeView. You should populate it by recursively traversing your AVL tree and adding TreeNodes to it. It is simple and quick solution. The disadvantage is that the final result will not be like in your example.
You will get a similar effect if you use WPF technology and its TreeView and TreeViewItem classes.
The result similar to your example should be achieved with Microsoft Automatic Graph Layout. I used it quite intensively and I can recommend it. It is also not difficult in use.
I would suggest to use WPF. You create a Tree obvject that you bind to a hierarchical control.
As soon as you add items to the tree the UI will update. I would suggest it always over Winforms. Do yourself a favour and do not use them

Composite view navigation in PRISM

I've searched online and was unable to find a specific answer to this question so I thought I'd asked. Sorry if I've missed the answer else where.
I work in an application that uses mvvm / prism framework and I'm wondering it it is possible to navigate to a view and then open a specific composite region within it allowing me to reach an end state that would normally taking clicking through a tab control.
Is this possible to do but only when I press a specific button rather than it be the default view navigation.
If so would I do with on initial navigation, or pass a parameter to the new view that says then navigate to the composite views.
Any help would be appreciated.
No. Regions are not controls. You can define a region in a control, say content control, and define what view will be associated with the region. Whenever the control become visible in the visual tree, the regions(the associated view) in the control will be visible.

Change view when using WinForm and MVC

As part of a school project, a group and I will develop a Windows application using C#.
We are not very experienced in C# but has some basic understanding for it. We do however have experience from other languages and platforms.
We would like to build an application in which the layout is split into two primary parts: the menu, which will reside to the left and the content which will be to the right.
The menu will be more or less static and when an entry in the menu is chosen, the content will be changed.
We have not been able to figure out the best way for achieving this nor have we been able to find good material on this. The idea is to have one window and add a view (as far as I can understand, this should be a UserControl?) to this window. This control will be the menu.
Now, our question is if anyone can point us in the right direction to achieve the navigation in the program. Say, when a menu entry is clicked, how will we change the content of the window and how will we manage which view is active? I suppose that every view (in the "content area") will have a controller.
We are interested in the "best practices" for this when using WinForms and the MVC pattern.
We hope that someone can help us further in this project.
If I were you I would seriously consider using WPF instead of winforms.
It, and the use of the MVVM pattern, allows you to do some pretty impressive stuff with far less code than if you are using winforms. If you don't already know winforms then it might also be a slightly less steep learning curve as WPF is a better thought out framework (at least in my opinion).
If you go the WPF route spend some time getting to understand how bindings work and how to bind your ViewModel to the UI. Once you have a good understanding of proper UI separation you are able to do far more than you could with the old WinForms framework.
I found this link quite useful when I first started looking at WPF. Especially the RelayCommand.
If you are using Winforms the options that you have got is:
-dynamically clearing forms and generating content on menu navigation
-using mdi container form, which can be parent to a number of child forms
If you are using for WPF you could use Pages in a Frame control loaded based on used menu selection. You could also use MVVM pattern to build your app.

Force visual tree creation with Prism

I have a TabControl containing Prism regions. I want to trigger some kind of notification (e.g. flashing the tab header) for certain events, and I want to trigger this notification from the components in the Prism regions.
Once the tab containing such a component was open once, this works nicely using VisualTreeUtil.GetParent() and going up until I find my TabControl and can modify it to indicate the notification.
But the problem is that this doesn't work until the tab is opened by the user because VisualTreeUtil.GetParent() returns null; obviously because Prism doesn't hook up the visual tree until then.
Calling UpdateLayout() on the TabItem containing the region doesn't help. I don't want to open the TabItems programmatically, because this would confuse the user.
Is there anything I can do short of implementing a kind of region registry (which would be rather ugly and harder to maintain)?
If you want to look at code, I wrote a minimal solution to demonstrate the issue. The Print Structure button tries to go up the visual tree from the (initially unrendered invisible) hello TextBlock on the second tab. Before you switch to the tab it prints only the TextBlock, afterwards you get to the root of the visual tree. This is what I want to accomplish without switching to the tab.
Adding comment as answer:
This probably isn't exactly the answer you are looking for, but it seems like you're taking a very procedural approach.
Have you considered using an MVVM approach? Each TabItem in the TabControl can have a HeaderTemplate. In the template you can bind to a property in the ViewModel that causes the tab to flash or change appearance
Hm.. IIRC Prism regions are just a configured ContentControl/ContentPresenter. Once they are ready to work, all the bindings and datamodels should be in place, but the trees are left not created because they are invisible. If so, you should be able to call ApplyTemplate() on them to force it. I do not remember, however, if the Prism assigns the contenttemplates/datacontexts upon init, or upon demand - the latter may cause calling ApplyTemplate useless.

WPF - Content section control

I am new to WPF and am trying to find the right control.
I am coding a WPF app that has two sections. The left side is an Outlook like sidebar (Odyssey controls).
For everything else I want a control that I can easily swap the contents of based on what is in the side bar.
So the user selects an option in the side bar and all the controls in the main section would change.
If I was writing this in Windows Forms I could just create a few Panels and then show the one that is relevant (and hide the others). When I try this in WPF you can see the contents of the panel underneath. I know I could make them not visible, but I am getting the feeling that I may be going about this the wrong way.
So here is the question. What is the best way (in WPF) to handle content sections of the app to change.
Based on your example (switching what is shown based on what is selected in a side panel) I'd recommend restyling a TabControl because that's really tab switching even if it doesn't look like it. Check out this for a decent example, set TabStripPlacement to Left and you will have a good start.
Depending on how your data is set up a Master-Detail pattern might be another good choice.
If you want to switch everything programmatically you'll want to use a ContentPresenter and DataTemplates for the UI "panels". This article by Josh Smith is about MVVM but his example application is basically the pattern you'll be looking for.

Categories

Resources