I have used a list view that uses a grid view in WPF. I have bound the grid with data and I want to handle right click event on the items of the grid view. Can someone help me out and suggest how to do this??
This question seems to provide what you need:
wpf listview right-click problem
Related
In WPF, I am trying to create a settings page like the one in Visual Studio (Tools -> Options) (http://i.imgur.com/Be9cTPF.png)
I realize the selection menu is a treeview but I am unsure how to hide/show the controls on the right.
What is the best and proper way of doing this in WPF?
In my opinion the best way to do this is to divide the page into 2 grid columns. In your first column, you can place the treeview. The second column will consist of the data page. You can bind the visibility of this grid column when there is a selection in the tree view using a converter or so or display a default view there.
You can handle the selection changed event of the treeview and bind the selecteditem to a property and as per the selecteditem you can change the view on the second column.
Hope this helps.
I'am developing a windows store application, I have used WinRT XAML Toolkit tree view control for display hierarchical data.
Tree view is populate and working correctly. But I need to do small change, in the treeview it has expander button. I need that functionality into heading item. When user click on heading it should work like expander button. I want to expand the node if user click that heading also. How can i do this? Thanks
You can put a Button or ToggleButton as an item or in ItemTemplate (depending on whether you are using ItemsSource to populate the TreeView with nodes) and handle a Click event on the Button to toggle the node's expansion state.
I'm working with WPF and the MVVM pattern and I need to append elements to the window from the ViewModel. The scenario is: the user will have a collection of textbox simmulating fields of a table to insert products, and there'll be a button to add more rows. My problem is just to create a way to make this button works. How can I do that ?
Is there a better way to solve a problem like this ? Needing to add many entities at once adding rows to a table ?
Thanks in advance for your aid.
Use an ObservableCollection in your view model bound to an ItemsControl. On the button click event add a new object to the collection. The UI will be notified that another object has been added to the collection and render the new row.
In my C# app, I have a ListView on a Form. I want the user to be able to double-click on a section of the ListView when no items are selected in order to pop up a "New Item" dialog. The problem is that the DoubleClick event for the ListView only fires if an item is selected.
Is there a way to do this?
There is a way to do this, but you have to do some low-level drilling into the Windows machinery. It's generally not a good idea to spend a great deal of time trying to get a standard Windows control to behave in a non-standard manner.
A simpler way is to just put a "New Item" button next to your ListView. If screen real estate is an issue, you could just add an extra row at the bottom that says "{click here to add new item}", and show your dialog when the user clicks this last row.
Add an event handler for the List view's MouseDoubleClick event.
Assuming Windows Forms:
Perhaps a good workaround would be to use a ContextMenu.
I have a Listview that uses databind. I set the DataSource property to a binding source. All works fine. The problem is that I need to have a column that is not databinded and contains only buttons that have the same handler for click event. To accomplish this I tried to add a subitem that is a button for each ListViewItem after InitializeComponent but doesn't work, nothing is displayed. Also I set the list view column type to Control.
If I add elements to ListView and isn't databinded that the buttons appear.
So it will be a great help for me to know if buttons could be displayed in column that is not databinded when the listview uses databinding for rest of columns.
Thanks!
The best thing to do here (assuming you mean ListBox), is to have a single button above or below the listbox, that uses the ListBox.SelectedItem property to investigate the selected item and do something with it.