I have a simple winforms form (used as a modal dialog) with several controls on it. I want to display a tooltip for one of the textbox controls. I have added a tooltip component to my form, and did a 'SetToolTip' call in the constructor of the form for the desired control. I am using default values for the various delay properties.
Display of the tooltip is very erratic. When the mouse is over the textbox, sometimes the tooltip displays. Sometimes it will only display when I move the cursor while over the control. Moving the cursor out and back in may get the tooltip to display. When it does display the timing seems much longer than InitialDelay. If it does work a few times, it then stops working, and no amount of leaving/entering the control will make the tooltip appear again.
I tried setting ShowAlways to true, but that didn't make any difference.
Any suggestions for getting my tooltip to work reliably?
Thanks.
I've had tooltips working reliably before and here's what I did to replicate it.
I placed a textbox, label and ToolTip control on a form which I'm using as my modal dialog.
My MouseEnter event handler for the textbox looks as follows:
private void textBox1_MouseEnter(object sender, EventArgs e)
{
int XOffset = 0;
int YOffset = -55;
int Duration = 3000;
toolTip1.ToolTipTitle = "ToolTip.";
toolTip1.Show( "This is my tooltip. there are many like it but this one is mine",
textBox1, XOffset, YOffset, Duration);
}
That's it. The ToolTip appears for 3 seconds when I enter the textbox with the mouse, then disappears, and does so consistently. Note I didn't have to call "SetToolTip" anywhere. Also, make your offsets so the tooltip isn't obscuring any part of the control as this seems to cause weirdness.
Related
I have UserControl, which contains Canvas (in Grid).
When I just clicked on canvas event PreviewMouseLeftButtonDown or MouseLeftButtonDown works perfectly, but when I set canvas.Background = new ImageBrush(imgs); and try to click on canvas, events doesn't raising. I tried to make same events for grid (canvas parent), but result was the same.
UPD1: canvas has children - rectangle (from System.Windows.Shapes) around cursor, maybe it somehow affect on events.
In wpf there are two possible scenarios where hit testing (clicking with mouse somewhere) is not working. These two are ment to be that way and it is by design. I am talking about when your Background is NULL or when you have the property IsHitTestVisible set to false.
In any other case hit testing/clicking will work.
I assume your background is null somehow. Maybe imgs throws error which will be catched in an empty try/catch block internally at render time.
Tell us is the background property of your canvas null?
There is a nice tool called Snoop which allows you to snoop an wpf app and change properties at runtime. Use that tool to change the background and tell us about the results.
EDIT:
First of all the default value of Canvas Background is null therefore by default you can click as often you wish on Canvas and nothing will happen.
As soon you change the Background to Yellow it clicking will work and your handler will be called.
I have created a custom popup to decorate my buttons with animated tooltips. I track Button.MouseEnter for the button to decide when to display the popup. I use Button.MouseLeave to determine when to hide the popup.
Problem is Button.MouseLeave is fired prematurely if the popup moves over the mouse cursor (its appearance is animated) despite the fact that I have set IsHitTestVisible = false for the popup and all its visual children.
Is this the way WPF is designed to work? I need MouseLeave to only fire when the cursor moves away from the button itself and not be influenced by the popup.
Thanks
I believe that the Popup control is actually contained within a window, which is why the popup can extend beyond the window bounds in some cases. (It's also why popup transparency is not supported in Silverlight.)
I believe that while the popup control is no longer processing "hits", the container window is, which is why you are losing your button's mouse focus.
I've not tested this, but you might try creating a template for your button and actually declaring the popup as part of the button (rather than below it). This may cause WPF to view the popup control as part of the button and eliminate the problem of losing mouse focus. This works in other scenarios, but I'm not 100% sure how this will work with a Popup.
EDIT: As a side note, the deault WPF tooltip allows you to override the template. I'm not sure what your goals are, but you may find it easier to change the appearance and behavior of the default tooltip than to try to roll your own, as a lot of these sorts of problems have already been solved in the default Tooltip.
I'm developing a Windows Forms Application. See attached image for the Interface. Now I've put a close button (X) in the Panel(say Panel2) which has Application Constants as label.The first combo box is in another panel(say Panel1). Now when I click on the X button in Panel 2 I want the Panel to be invisible and the combo box text to be blank. Simple enough.
So I write
Panel2.visible=false;
comboBox1.SelectedIndex=-1;
When I click on X, the text in combo box goes blank, then I have to click again for the Panel2 to go invisible.
Then I changed the sequence
comboBox1.SelectedIndex=-1;
Panel2.visible=fasle;
and this works smooth. Not sure why this might be happening? Is there anything that I might be doing with my form design/code to have such a behaviour?
I expect that you have an event handler on comboBox1 for SelectedIndex changed, which makes the panel visible for some reason. Moving the setting of selectedindex before the hiding of the panel fixes this.
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
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.