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.
Related
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).
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 have made one custom user control (search text box), which basically consists of one dock panel, and in the panel there are two controls: textbox and button.
I have set some default appearance for this control, which consists of setting a border on the user control, and setting no borders and no background on the textbox, and I have created a custom style for the button. So far this control looks the way I want, and is working correctly.
The problem arises when I want to allow themes for my application. When I put custom styles for basic windows controls (Button, TextBox, ListBox, etc), they are displayed properly with the new theme. But I don't know how to make a template for my custom control. Any attempt ended up in the control not showing at all at runtime.
What exactly must be done in the new template for this control? Do I need to make a template for the User control, and for the textbox and the button controls also?
You are mixing up user controls and custom controls here. What you described above is a user control, and you cannot apply new templates to it.
I want to add the menubar to TextBox control in Silverlight 4. (I will create a new reusable control.) The menubar will consists of a few image buttons. The idea is that it will normally stay hidden and will show up only when the user puts his/her mouse cursor to the TextBox area. If used in a multiline textbox, whole menubar can fit inside it, this should be easy. (I hope. :-))
But how to solve situation when TextBox is in single line mode? I'd like to put the menubar above the TextBox. But I don't have a clue how to do it. Can somebody help? I need to let all other controls in a form to stay in their positions, and only add my menubar above my textbox. (So the menubar will NOT hide the textbox. Instead, it will hide other controls residing right above the textbox.) It should work in all arrangements of form, like Grid, StackPanel, Canvas etc. In the fact it would be similar to a classic right-click context menu, but not modal. (Right-click context menu is modal, i.e. while it is shown you cannot use other controls, and it automatically hides when you click anywhere else. I want my menubar to stay visible as long as user heeps mouse cursor over the textbox or the menubar.)
Example: Coordinates of textbox are top=100,left=20,bottom=115,right=120. So my menubar's coordinates should be bottom=100,left=20, right & top are based on size of menubar.
If many textboxes will be used on a single page, each single one should have its own menubar. (Of course.)
You can create your own control (custom control or UserControl, whichever you like should work) which has the TextBox, and the visual for the menu bar.
If the TextBox is single-line, you could display the menu bar in a Popup which you position just above the TextBox whenever the mouse is over it.
If the TextBox is multi-line, you'd simply use a StackPanel or Grid or whatever to do layout like normal, if I am understanding what you want.
No coding required if you use this menu:
http://sl4popupmenu.codeplex.com
To achieve this behavior you will need to set its IsPinned property to true.
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