I want to unload a user control on the click of a button inside the user control. I am calling this user control inside navigation:page for the filtering the rad gridview.
I think Making the visibility collapsed wont unload it.
Any ideas?
Remove it from visualtree. Suppose that your control "myControl" is contained within Panel derivate called "LayoutRoot" then you can do this:
LayoutRoot.Children.Remove(myControl).
Related
I am currently working on a project which has a tab control which contains a Wrap panel which contain a series of user controls. I am looking for a way to allow the user to select one user control and maximize it to the size of the tab control/window.
One thought is to simply remove all the other items from the panel.However I am attempting to use MVVM as much as possible and I'm not sure how much the user control should know about the panel. (The user control will contain a button to allow maximizing)
Is there a way to temporarily remove the usercontrol from the grid and treat it like a modal popup or just to fill the window?
How about having "Visible" or "Maximized" bool properties in the view model for each user control based item, and databind said user controls Visibility property to the appropriate property. Then bind your user controls maximize/restore button to command in the view model to change the VM properties appropriately?
I'm trying to create a button in main window that would look like a globe, which would allow user to select his/her location. I want it to display a listBox when clicked on it just below the button itself.
Any hints on how to do this?
Probably the simplest way to do this is restyle a ComboBox and then restyle the ToggleButton in the ComboBox and remove the editable textbox.
This will avoid you having the implement the functions of the ComboBox for your popup.
Try using this as a starting point.
Another Approach would be to use the Expander Control with a list box in it
Link
OR
You could play with the Listbox's visibility property
I'm developing my custom menu. It behaves like this. I have one toggle button and pathListBox that positioning menu items (buttons) into circle. So I have Menu user control that contains toggle button and one pathListBox. So I don't know how to put menu items inside pathListBox. I want to write
<my:Menu>
<my:MenuItem>
</my:MenuItem>
</my:Menu>
How to get this content of the user control into pathListBox.
Tnx!
Consider building a true Control or ItemsControl; UserControl derives from ContentControl and is not well-suited to building controls with many items being presented.
My WPF application consists of a main window with a tab control which has a series of tab items, each hosting a user control.
I'd like one of the user controls to be able to trigger the application to change focus from the current tab to a different one.
Is there a way for the user control to trigger its tab control container to change to another tab item?
The WPF system provides the RoutedEvent. This special kind of event can be created to be catched by every element in the tree. With this way you can fire the event inside your user control, and catch it in the TabControl that will do everything you need. The tab control can catch the event cause of it lies in the element's tree of your window.
You can start from here:
http://msdn.microsoft.com/en-us/library/ms742806.aspx
You'll need a Bubble Event.
Hope this helps.
You can have a property that binds with SelectedItem property of TabControl.
I have a customn control which display a window with another custom control inside. The developper can redefine the control template, it works but I don't find a way to allow developper to redefine the template of control inside the window that the custom control display...
Ok, I found. The solution is simply to set the other control as a dependency property inside the first (parent) control...