Button change sized using Mouse - wpf

I would like to know if there is a way to resize a button Width using the mouse, like when you are in the design mode, I'd like to change the cursor to the resize cursor when the mouse pass over the edge of the button, and with a sutained click resize the button.
thanks !!

You should look into using Adorners for this. Here is an article on Code Project that describes how to "drag, resize and rotate elements on a Canvas", with and without Adorners: WPF Diagram Designer: Part 1

Related

How to scroll contents WHILE scrolling

I have created a usercontrol that is essentially a text editor (using Graphics.Drawstring in OnPaint).
I have set AutoScroll = true, and AutoScrollMinSize values appropriately. Everything is working how it should...
EXCEPT, i would like the control to scroll itself WHILST I am currently scrolling (i.e. click and drag the scroll bar... and whilst it is being dragged the control should be scrolling the entire time). At the moment it only scrolls when the scroll bar is released (mouse up).
I have tried implementing _Scroll and invalidating the control, but that just makes it flicker uncontrollably.
I cannot find any examples online for this, due to it being difficult to describe!
Can anyone point me in the right direction please?
Control.Invalidate() will make something flicker badly. I faced this problem drawing cross-hairs over a mouse position on a PictureBox drawing a line chart before. The trick is to use (and I cant remember which one is best to come first)
Control.Update();
Control.Refresh();
in the Scroll event. Depending on what else you are drawing in the Control and how you are drawing it this may be better for you. Also this is tested on PictureBox, Control may be another matter.

Where do I find an icon of a mouse pointer?

I want my WPF application to have a ToggleButton that contains an image of the mouse pointer in it. The idea is that the user will choose one of three different cursors (the normal mouse cursor, the hand cursor, and a "zoom" cursor) by clicking on a ToggleButton. I want the cursor image to show on the ToggleButton.
How do I get these icons onto my button?
Tony
If there are only three options, why don't you search for three images, and check the mouse around the, say, 30 secs and adjust the button, if needed.

Silverlight canvas does not resize on maximize button press

In my Silverlight project, I have a couple canvases that all use ScaleTransforms to resize as the browser window size changes. However, if I make my browser window very small, then click the maximize button in the browser, the app stays the same size. How can I make it resize properly when the maximize button is clicked?
The canvas resizes up and down properly when I am resizing the window using the edge.
Have you tried wrapping your canvas with a Viewbox?
It turns out that the delegate for a resize event was being called after the resize happens (which makes sense); but that I had some conditionals that would prohibit it from resizing if it was already 800x600. If you resized the window quickly, it would not resize properly since it thought it was 800x600; but had in fact shrunk.
tl;dr - I did not code my resize event handler correctly.

How to specify z-index for a panel

Hi I'm new to WPF and I want to place a Panel upon a StackPanel and show and hide it in my window without using Canvas and changing positions and size of other controls or the window.
Something like the fallowing image which the solution explorer is opened on another Panel, and as we see the user even can change the position of the Panel.
If you have a Grid as the Root Layout and a StackPanel on that, you can still use Canvas.
Canvas.SetZIndex(<YourPanelYouWantInFront>, <LargeValue (100)>);

Center a Silverlight modal popup in a canvas that is larger than the screen

I currently have a Silverlight canvas that exceeds the viewable area of the screen (I'm letting the users drag the viewable areas around to navigate). I'm trying to display a modal popup that always shows up in the middle of the viewable area, and I can't seem to find any property that tells me what currently is on the screen. Basically if the user has panned down to the bottom and clicks something that causes a modal popup to appear it is stuck at the far top of the screen.
Any ideas anyone?
Thanks
~Steve
I don't think this is possible since the visibility isn't being surfaced. Perhaps with some fun JavaScript to figure out where the panning is?
Quite true. I wound up creating a holding canvas, making that full screen, and putting everything else as a child canvas within that. The modal popup now comes up in the holding canvas.
Gabriel GuimarĂ£es one works good.
App.Current.Host.Content.ActualHeight(and ActualWidth) does bring the browser size inside. Good for calculating position. And of course you can use LayoutUpdated on your main control to double check the sizes and resize stuff if need be.

Resources