wpf user control to display on top of current view - wpf

I wish to have a user control in my application. The behavior should be similar to a tooltip. That means, when I move the mouse inside my view, this user control also moves.
How to achieve this.
I do not wish to have draggable canvas, just that the top and left of the control change. Actually what i wish to achieve is quite similar to a magnifier. But instead of displaying a digital zoom image I wish to display a cropped image inside the magnify viewer.

You can also use the Adorner class. Hope this solves your problem.
Adorner Class Description (MSDN)

Related

WPF Popup Alternative

I have a window with a popup that pops when an item in a listview is double clicked.
It centers to the main window and looks really nice floating there.
The problem is when the user moves the main window or selects another program, and the popup floats on top of other stuff.
I would like to have something like a popup, meaning that it floats on top of other elements in the window, but sticks with the main window when it moves (stays centered), and doesn't float on top of other programs.
Can I make a popup act like this, or is there a better way to do it?
Popups will not move while the window is resized or moved. Because, Popups/Context menus are not the part of Visual Tree. You have to use Adorner for this. I will suggest to read this four part series for a quick start on Adorner.
It's possible that an Adorner will fit your needs in this case better than a popup. Adorners can float above your window, too. There are a few differences, mainly that an adorner is bound to a UIElement (which include windows).
If you are willing to use a third-party/open source (MS-PL) option, the Extended WPF Toolkit has a ChildWindow control.
It's technically not a separate window, but it appears to be a separate window to the user.
I have not found a way to make Popups stop doing that in WPF
As an alternative, you can create a UserControl which acts like a Popup.
Usually I host the content section of the app along with the Popup within a Canvas control, and when IsPopupOpen gets changed to True I set the popup Visibility = Visible.

Transparent overlay which does not scroll with its parent

I would like to have a form which has a few controls as transparent overlays over a bitmap. This bitmap is subject to transform matrix (zoom & scroll). I'm trying to achieve a look similar to GoogleMaps where the controls do not move when the background image is panned/zoomed.
I've tried to mimic this in my OnPaint. However, when the window is scrolled only the newly exposed area gets invalidated so my control doesn’t repaint.
I've tried to calculate where the old control was, invalidate that area, and also invalidate the area where it's supposed to have been. When I do this it flickers and you can still see the image as its scrolled.
I tried to put a ButtonControl on my display window. However, it always scrolls with its parent control. I tried to capture the scroll events and then adjust the position of the ButtonControl. This also has a delay update effect so it looks not so good.
Any ideas would be greatly appreciated.
It sounds to me like you need to Invalidate() your control wich handles the OnPaint event.
Unfortunately, you get the flicker because the Auto-scrolling mechanism sets its position, and then you restore it. The result is two messages being sent to the button.
Place your bitmap and scroll logic in a separate control that fill the entire form. That means both your bitmap control and the button are child controls of the form.
Alternatively, draw the button yourself. You will then of course need to do some work on getting it to respond to mouse clicks etc. The ControlPaint class has methods that help you mimic the appearance of Windows controls.

WPF UI Related question

realy i don't know what i should title this problem, i hope to "WPF UI Related question" is accept able.
consider something like that form who you explore a class diagram in Visual Studio.
you select any class object in window and than right click on it then you select "Properties" menu Item and then a window will pups up that allow you to change selected class object.
or something like Auto Cad. when you draw a line you can right click on it and then select Properties menu item and then with appeared window you can change line's properties (like color of line or any thing like that).
now i want to create an application with an User Interface like these who mentioned on upper lines.
i want to create an UI that i cad draw circle and squares on it (with mouse clicks) and then when i want a "Properties" window will appeared to change objects's properties.
also with this capability that wheeling mouse wheel up-down will results in zoom in/out the screen (like Auto CAD).
finally my question is that is there any kind of frameworks or pre created controls that i can use them for achiving these goals or i have to implement all these my self?
thanks all and sorry for my bad english..
You can use this for your property grid:
WPF Property Grid
for giving zoom capability i use this and for property windows i use this.
thanks to Yogesh...

WPF page layout control selection

I have an imagebrush of a soccer field as the page background and I want to be able create a line up by dragging players off the bench and positioning them on the field accordingly. I don't know what control to use for the background that allows the PlayerCard control to reside where it is dragged. Any help as to how to begin would be appreciated.
You can get the idea here.
What control to use?
I believe you want the Canvas container control. It lets you arbitrarily place child controls with a Left and Top attached property, similar to the way Windows Forms does it.

Clip a wpf Popup at bounds of a main window

From what I understand, the popup exists within it's own visual tree. However, I've noticed a few properties, Clip and ClipToBounds. What I am wanting to do is Visually clip a popup at the right and bottom edges of a window regardless of the fact that the popup is independent of the bounds of the window. I'm not using XAML, but if somebody knows how to do it in XAML, then that's fine. I can get to the main window using System.Windows.Application.Current.MainWindow. Is it possible from this to get a value that I can use to clip the popup? I'm assuming that if there is a value that I can use, then I would be able to bind the clipping of the popup to that value. This is really not necessary since after the popup initially opens, if the window gets moved or resized, the popup closes. So I would really only need to clip the popup when it opens. The reason I would like to do this is because although I am using a popup, I don't want it to appear as a popup that exists outside of the window. FYI this is for a popup calendar for a custom datebox. Any ideas, as well as clarification of misconceptions that I may have, would be greatly appreciated.
Furthermore, the popup can be launched from a user control that is not directly on the Main Window. So in that case it would be easier to use a popup. As apposed to a UC inside the XAML
I know this is a year old post, but in case any others come here looking for answers... If you don't need the popup to be outside of your window, why use a popup at all? It'd be far easier to simply use a control in a canvas (for instance) and control it via its Visibility property. Then you'd automagically get your clipping.

Resources