alt text http://img375.imageshack.us/img375/9830/combobox.png
Setting the IsHitTestVisible="false" has the effect of having the whole ComboBox's drop area unresponsive to clicks. The same goes for setting to true.
With a ComboBox I don't have to create any storyboard to make ComboBox animation like but I found this issue.
How can one make the ComboBoxItem area unclickable except for the button within?
Sounds like you should be creating a custom control that uses a popup window, that just looks like a combobox, however you can do what you wanted:
Put your buttons inside a grid, inside a single RadComboBoxItem
Set the grid background colour to 1% alpha so it is hit-test visible yet unseen
Add a Grid_MouseLeftButtonUp event handlern to the grid
In the handler set e.Handled to true so the mouse up is eaten
Make sure you close the combobox popup when you get your button presses.
Hope this helps.
Related
I have ComboBox which is data bounded to a collection.
I have customized the Vertical scroll bar of ScrollViewer, which will be in the center instead of normal right hand side of content presenter. It is working fine.
I have customized style for IsHighlighted trigger.
Issue: If I press the down repeat button it goes down and this is expected, but even if I disable the down repeat button, pressing on down repeat button highlights the item.
Any idea?
I don't fully understand the layout, a screen shot or a schematic drawing would help.
My guess is that you're using the "mouse over" and not the "mouse directly over" property to determine which element is under the mouse, so more than one element responds, but this is really a shot in the dark.
Actually the problem is in the ControlTemplate of ComboBox.
In ComboBox's control template I have used ScrollViewer and inside the ScrollViewer I used StackPanel. That is causing the issue.
Later I changed to ItemPresenter, now it is working fine.
This time I have a hard one for you :-)
Currently I am about to develop a usercontrol in wpf. I want this control to open up a slider as soon as one presses the mousebutton on a specific button within this control. The user should be able to move this slider as long as the mousebutton is still pressed.
As soon as the user releases the mousebutton the slider should disappear.
I already have a solution for this, but it's a very hacky one, because I am doing it through screen coordinates.
Is there any way to do this in a pleasant way with WPF?
Any help is highly apprechated!
Regards,
Michael
Please answer these questions first
What is your current XAMl and code behind?
While pointer of the slider is getting dragged along its length, do you want the button to be kept pressed all the time?
If so, did you use ToggleButton because it can be pressed throughout and can be toggled (unpressed) when you set its IsChecked property to false (i.e. when user releases mousebutton).
Have you checked mouse button state as Pressed (from button event args e) when mouse moves, being dragged, over some element such as the slider here?
e.g.
e.LeftButton == MouseButtonState.Pressed
EDIT
Related to point no. 2....
The reason why I suggest ToggleButton is because only that can be kept pressed while you slide on the slider. Otherwise with normal button, you can open the slider popup on button click but the button will loose its Pressed state when you move onto the slider.
Further, the IsChecked property of the ToggleButton can be two way bound to the IsOpen property of the slider popup. This way when the user stops sliding and releases the mouse, we can set IsOpen of the popup as false and that will automatically unpress the togglebutton due to that two way binding.
I have a textbox and some labels inside the data template of bounded listbox.
When I click on any label the whole item is highlighted in blue, but when I click directly on a different textbox the selection does not change.
Is there a way to make the selection of the listbox change even when a textbox is clicked?
thanks
This is what I've exactly asked few days ago, see post: "WPF: Trigger SelectedIndex changed whilst clicking on any control within a ListBoxItem area"
basically there are few solutions, using code behind and XAML, but I've not verified latter approach yet
The reason is because the TextBox handles the click event in order to receive focus. There are a number of ways to handle this, including but not limited to:
stop the TextBox handling mouse events (which prevents the user from focussing it using the mouse)
use an eventhandler when the TextBox gains focus (or PreviewClick or similar), to select the parent ListItem
I'm writing an XBAP with a complex Popup (Canvas Z-index of 99 with a grid on it...) that I would like to "attach" to the button that opens it and follow that button around wherever it goes on the screen. For example, if the button is in a ListBox or an XamDataGrid I would like the popup to follow the button as it scrolls through. If it is beneath an Expander I want it to stay attached to the button when the expander forces it to move, etc.
Any Ideas?
When using a Popup, neither PlacementTarget nor CustomPopupPlacementCallback is used after the popup has originally appeared. So any use of these properties will not allow the popup to track the button as it moves.
Several ways occur to me of achieving what you desire:
Attach a custom Adorner to the button and put the popup inside it. Disadvantage: Popup is not connected to Button or surrounding elements, so it won't inherit properties & DataContext from them.
Attach a custom Adorner to the button. This adorner will get measure and arrange calls when the button moves relative to the AdornerLayer, allowing you to manually update the Popup position. As long as your AdornerDecorator doesn't move relative to your Window (eg if it is the direct child of the Window), you can easily detect the AdornerLayer being moved by monitoring changes to Window size. Disadvantage: Complex to code & get right.
Don't use a Popup at all. Instead wrap the button in a <Grid> alongside a <Canvas> with zero width and height and the desired position. Inside the <Canvas> add the UserControl for the popup with an appropriate ZIndex. It will extend past the edge f the Canvas, which is just fine in WPF. Instead of using a Popup control just control the visibility of the UserControl. Disadvantage: Will not really be totally on top of all other objects, can't extend off edge of window (may not be an issue for XBAP, though).
I'm not sure if it will auto-update for you or not, but the PlacementTarget property allows you to specify a control to position the popup relative to. If that doesn't work, then maybe CustomPopupPlacementCallback will do the trick?
I have a button with a transparent background on a wpf window.
Problem is, when I open up another window with a .showdialog the form becomes disabled as does the button, causing the button to go white (and stick out like a sore thumb); the same happens to the listview and textbox controls. Labels and group boxes aren't impacted in this way and remain looking fine.
How do I preserve the transparency color of the button, listview and textboxes when they are disabled?
Thanks, Rob
I'm not sure what your button template looks like, I would recommend posting your XAML. But check out the MSDN Docs on Button Templating