I am using a third party charting library (Infragistics xamChart). I am not satisfied with how tooltips are displayed on a line charts datapoints so I was thinking of using an adorner to make a better looking/interactive tooltip.
What I want to do is have the adorner popup whenever one of the datapoints is hovered over. Does anyone have any pointers on how I can do this? Most of the adorner samples I found are pretty simple ones that just alter the entire control they are adorning.
My main questions are:
Is it possible for an adorner to
appear only when certain elements are
hovered over (and have it appear at
the current cursor position)?
Does anyone have a simple sample they
can share?
Are adorners the right way to go
here? I think the only other option
was to use the popup control but I
though adorners were a nicer
solution.
Thank you.
Perhaps Attached Behaviours could help you? From this article:
The idea is that you set an attached
property on an element so that you can
gain access to the element from the
class that exposes the attached
property. Once that class has access
to the element, it can hook events on
it.
That way you could attach a listener to the MouseEnter event and display your custom ToolTip from there.
Related
I'm making a custom dropdown button (since the one included in wpf requires too much hacking to style right). Now that i got the button bit out of the way i need to add the drop down part.
My first thought was to add a stackpanel and use that to contain the items but it gets cut off if it leaves the borders of the grid that the button is in. Next up was the popup primitive, it gets on top of everything nicely enough but position wise it just free floats and i haven't figured out how to make it follow the button it was spawned by. I also tried using contextmenu but that seems to have no positioning controls at all and just sits where the mouse made it..
Anyways wpf is a big package and I'm just getting into it, anybody know which direction i might find what I'm looking for?
Preferred approach normally is to use a Popup. You got two very important properties with a Popup
PlacementTarget and Placement
Setup a binding for PlacementTarget on the Popup to your custom Button and then use Placement to position the Popup accordingly w.r.t to the PlacementTarget(Button)
Placement accepts an enum of type PlacementMode which gives you quite a few options to position the Popup.
I created a class based on UIElement and my intention is to render it myself overriding OnRender. Rendering works fine. Next I want to implement focus management and continue with other aspects of LIFE, but overriding GotFocus and calling Me.Focus() in it don't do a single thing. I places my control on a Window with one another control - TextBox, and clicking on it doesn't do a single think. Tab doesn't set focus too, and TextBox is AcceptsTab negative. I know I will have to visualize focus somehow in OnRender to actually tell when the control is focused or not, but first I need to allow it to receive focus and that's where I struggle. Could you please help me out?
P.S. I tagged this with FrameworkElement because I don't have enough reputation to create a tag UIElement and leaving tags empty seemed like a silly thing to do.
Converting my comment into an answer:
I think you'd probably be better off deriving from FrameworkElement instead.
I want to show all the ToolTips on a view as soon as it's opened. That's fine, I can set the ToolTip.IsOpen properties to true. That certainly shows the ToolTips, the problem is they all show up at (0, 0). Apparently the positioning of the ToolTips doesn't happen until its target control is hovered. Only after hovering are the ToolTips positioned correctly. Setting focus to all the controls first doesn't help either; the target control has to receive the hover event. I'm assuming the ToolTip hooks into the hover event of its target and positions itself inside this event. Is there a protected method I can call in a ToolTip subclass or some such?
ToolTipService.SetPlacement(button1,
System.Windows.Controls.Primitives.PlacementMode.Top);
See this MSDN Page to see all the placement options
EDIT
See this article about the custom positioning of tooltips. It refers to a project on codeplex that contains the code: SmartToolTips
As far as I can tell what I'm asking here is not possible beyond manually doing layout or customizing the source. I implemented a completely custom tooltip instead. sigh
I have a control template defined, call it myVal, that is used for validation - this is then used for example in a Style targeting textbox where its Validation.ErrorTemplate is set as
Now say there are a number of such textboxes that sit in a view and that this slides in using TranslateTransform and BeginAnimation.
The result is that the adorner used in the ErrorTemplate doesn't follow the position of the textboxes as the view transitions - instead these stay in the starting position. However, the adorners reposition themselves correctly in relation to the textboxes as soon as I set focus or events such as mouse move.
How can I get the adorners to show in the correct position after the transformation without having to change the focus? Is there a way of delaying the validation until after the transition...or how can I "revalidate" the properties once the animation has finished? I read somewhere about calling invalidatevisual but can't see how I'd do that. Any help is much appreciated.
Cheers
Two ideas:
Try adding an AdornerDecorator around the textbox, or around the group of textboxes. This will tell WPF to add another layer for rending adorners. Adding a layer "closer" to the textboxes might help.
If you want to tell the adorner layer to re-render itself, then you can use something like the following code:
var al = AdornerLayer.GetAdornerLayer(myTextBox);
al.Update();
I am new to both Silverlight and Blend 4.
I am trying to make a Image Gallery, where u click on the image and it shows details of the same.
I used VisualStateManager to get a mouseOver and mouseOut effect to the thumbnails. and here is wat i want. I want to add the VisualState's to all my thumbnails through Style. (I had seen this in some forum, but i cudnt figure it out how he did it.)
Here is wat i want:
I have set of thumbnails to, which need to scale up on MouseOver and come back to normal on MouseOUT. I created a VisualStateManager States.
But i want to use the state as a
common state for all the thumbnails
and apply it to the thumbnails through
Style.
Is this possible? If so how?
If not? then is how can i achieve it.
Would be really thankful to any one who can help me :) just that this is a bit urgent. :(
MSDN documentation says that you should be able to add the VisualStageManager XAML tag to any control which inherits from UIElement and accepts child controls.
It seems to me then that the best way to do this is to create a UserControl for your thumbnail and set the VisualStateManager there. You can then reuse that UserControl.
More reading material:
MSDN UserControl documentation
Adding behaviour to stock controls