Now I just want to dropdown the combobox via code.
IsDropDownOpen = true;
So how to hide (not disable) the arrow button in combobox?
To hide the ComboBoxToggleButton, you would have to edit a copy of the combobox template.
Right click on the combobox and select edit template. Select edit a copy and give it a name. (You may want to put the copy in a resource dictionary of it's own considering the content size)
The generated ComboBox style will have reference to two templates, ComboBoxTemplate and ComboBoxEditableTemplate.
In each template, you will find a ToggleButton with x:Name:toggleButton, that is the toggle button you want to hide.
You can remove it entirely, or make use of your WPF given Visibility property. Your call ;)
I would consider putting a textbox on top of the combobox and hiding that part of it.
Something like:
<Grid>
<ComboBox Name="YourCombo"/>
<TextBox Name="VisibleValueTextBox"/>
</Grid>
You can bind the text of VisibleValueTextBox to that of YourCombo.
When you drop it down, the dropdown will still be on top of everything.
I'm not sure what your full requirements are but this is a quick and perhaps rather dirty approach which could work.
Related
I need to write a style for a listboxItem that will add a button on the right of the listboxitem when it is selected or mouse over. The button need to have a command binding as well .
This style need to be used in different places.
also the button won't have a border. but when the mouse is over the button , it will have a border.
How can i write this?
I tried to write a style, but i can't bind to the command of the button that is inside the style.
Code used: (sorry i wasn't able to paste my code normally here so it is here http://justpaste.it/1b9s)
It would be great to see some code but an option that should work is to create a DataTemplate. You can set it on ListBox ItemTemplate property and use it in the different locations where you may need it.
I have a style for a control and I'd like to add items to the context menu of that control. I was able to replace the context menu with my own but have found no way to add items to the existing one. Is this possible in XAML?
Thanks!
You can always toggle a MenuItem's visibility in XAML using bindings. This allows you to create one context menu but control the options displayed to the user entirely through XAML. This is what I've done in the past as it seems to be the easiest option.
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 have a MiniToolbar popup that shows up at Mouseover on a ListBoxItem, it needs to show just under the item.
(a MouseOver trigger also sets the IsSelected property on the items)
I tried two options :
define the popup on the items DataTemplate
define the popup on the ControlTemplate for the ListBoxItem
Both options work fine, however I was wondering if the popup was recreated each time ??
(please advise)
I think it would be better to define the popup in the ControlTemplate of the containing ListBox rather than the ListBoxItem ?
I tried this, but could not find the binding expression for placement property relative to the SelectedItem (it shows up at the bottom of the ListBox, not bottom of ListBoxItem).
Any suggestions ?
thanks in advance.
Michael.
The popup is created one time for each list box item in both cases.
I would not suggest that you use single popup for all items in the CotnrolTemplate for the list box because it significantly complicates things. But if you still want to do so, you can set Placement="Custom" on you popup and specify CustomPopupPlacementCallback. In that callback you can calculate the placement using the position of currently selected item.
Is there any property or state I can set on a expander object that makes it unexpandable but still can be selected?
I'm thinking for example of the last Child in a TreeView where I don't wan't the Expander to have an expander button. But other uses could be if someone doesn't have access to more then the header or something along that line.
The only way I know would be to create custom control template for expander, remove expander button from it and disable expanding.
See WPF Expander: Reversing the icon direction while keeping the content location (ExpandDirection) the same on how to create custom template for expander.