How to create List-like UserControl in WPF? - wpf

I want to create my own expandable/collapsable tree-like UserControl, which nodes are the Border elements with any content. And this control should have the single SelectedItem. When I select one of the nodes I want to see details information about selected item.
I've done the control's presentation and a piece of logic:
I can see all the tree of elements, collaps any node(s), select one of them and see details. But I can't do bidirectional binding. I.e. I want to have an opportunity to change fields in details panel and immidiately see changes in the tree-control.
Help me please either call force update (rebind data) of the control (just give a tip how to perform this) or give an advise how to create my own List-like UserControl.
I tried to make my control inherit from some ListBox class but I couldn't.
PS. Sorry for my bad English...

Use the TreeView control.

Related

PropertyGrid-like multiselection in other elements(listView)

i want to immitate the behavior of multiselection of items (eg. in a list view) and their appearence in a PropertyGrid. So, obly the same properties are shown and values set in the grid are set on all multiselected properties.
I have created a listview with some datatemplates and have in another listview some data(with databinding). Now i want wo have a multiselection on the listview with the data and have the properties shown in the another listview like in a propertygrid.(explanation: The ProprtyGrid is still not available in WPF and if has not the flexibility of showing data the way i need it)
So, how do i need to prepare my data to be shown in the list propertygrid-multiselection-style? Is that even possible???
Greets,
Jürgen
I'm not sure if this question is still active, or what not. But I have found a solution that works for me - and I need somewhere to share it.
The first issue you are going to have solve is selecting the items, ie. multi-select. See my tip here that explains how to do that.
Next, I guess its basically binding to listview's selectedItem property and how you want to update your propertyGrid based on changes to the selectedItem prop.
Hope this helps.

Silverlight How to load a usercontrol in a page based upon a listbox selection

I am trying to work though the best approach to accomplish the following. Within a page I have it divided into two section. On the left a listbox and the right is empty. (Grid etc). What I would like to accomplish is when an item is selected from the listbox a different user control loads in the right panel. For example if I have three items (one, two three) selecting one would load a red user control, two would load a blue user control and three a green user control.
I was taking this approach since Content Template / Data template selectors are not available in SL. However if anyone has another suggestion I would be grateful for your thoughts.
I'm creating this with MVVM in mind and traditionally I have managed this within the code behind of the user control however I have seen mention of how this could be managed within the ViewModel as well.
Any suggestions or guidance on a best approach is always appreciated.
Cheers
You can bind both listbox selected item and user control visibility properties to the same property in the viewModel.
Then just use a valueConverter for each user control to switch on/off the visibility.
Please tell me if i should elaborate/add a code sample.

Creating orderable list in WPF using ListBox (HOWTO or better approach?)

I've got a list of things that I want the user to easily edit the order of. Right now I'm binding them to a ListBox with a custom ItemTemplate. Within that template I have an UP & DOWN button. My goal was to move the item up/down based on the button clicked.
However I'm having trouble associating the button's click event with the actual item in the list. I've seen some folks setup a drag/drop for ordering items but that that would be too complex for this app (it's target user base =1, just me).
I assume this is possible with a ListBox. Maybe someone has a beter idea on how to implement this? It's not a huge set of data... less than 25 items.
The DataContext of the button (of the entire template, thus inherited by the button) is the item itself. Simply cast it to your desired type.

WPF bind to a list

I have a user control whose users I want to have them set a DataContext on to bind to a list of objects. In my control, however, I want to display that list in a Grid, but in a non-trivial order. The column/row of display of each element will be determined by some code I will write.
So I cannot do a straight databinding in my control, I need to write code that will read the DataContext and then do the processing to correctly position each element.
How would a relative WPF newbie go about doing that? I guess the part I don't understand is what the code in my usercontrol will look like to read the DataContext items so that I can process them.
EDIT: Clarification: I want to stress I want to bind to the XAML Grid element, not some other kind of grid or DataGrid. Thx!
One of the possible way to achieve that is to use a Converter. You could create a Converter which converts the input list into another list where the order has been changed. Then you could use a "normal" databinding which will use the Converter.

WPF ListBox getting item datacontext OnMouseOver

I currently have a view that contains a ListBox bound to a a collection of view models and a user control that I would like to bind to the current item that the mouse is over. How can I get the current highlighted item in the list and bind it to the user control using only XAML and code in the View Model?
Edit: The following image might be more descriptive of the intended action.
alt text http://img134.imageshack.us/img134/6263/34548010.png
As eduardo said, sometimes to make a solution in pure MVVM is too complicated.
if you reformulate your question and provide some code, you can get more answers.

Resources