Silverlight Planeprojection - silverlight

I have a user control that has a white background with a Zindex = 0. I also have an image on top of the white background with a Zindex = 10. When I use planeprojection to flip the image 180 degrees on the X-axis it just shows my image in reverse. How would I get it to show the white background when it gets flipped?

PlaneProjection inherently won't show the "back side" of a container. What you need to do:
Define two elements in your container: one for the front/visible side and one for the back/hidden side
When your PlaneProjection rotation is greater than 90 degrees, hide the front element, and show the back element. Vice-versa for switching back to < 90 degrees
I believe you can use the VisualStateManager to intercept when the rotation angle hits a certain value and to then apply the visibility.
Here is a Tim Heurer article on the VSM:
http://timheuer.com/blog/archive/2008/06/04/silverlight-introduces-visual-state-manager-vsm.aspx

Related

WPF - Create a border with line style as a saw-tooth (gear)

I need to draw a border or rectangle like a bill payment on shop.
For make it's as real, I need to draw a shredding effect with the bottom is a saw-tooth line instead of a normal border.
Would you please to give me some advises?
Forget borders. Terminate the bottom side of the white area as a normal rectangle, but stack immediately at bottom an image (e.g. PNG) with the perforation strip.
That's the easiest way, unless you need something that adapts to the rectangle's width.

ApplicationBar Edge or Border

I have a pretty standard application with a bar at the bottom. The bar and app are the same background color. My issue is that there is a tiny little line along the edge of the application bar, I can only determine that is it some sort of soft edge that is part of the default style of the ApplicationBar.
Here is an image of the display, note the tiny 1-2 pixel horizontal line:
It appears to be a 1-2 pixel black line with transparency. My main question is, what is this line, is it something I am introducing by accident?
It is by design a 1 pixel gap will be there between ApplicationBar and your ContentGrid. The gap will be visible only when your set the Opacity of the ApplicationBar to 1, So to get rid of the gap You can change the Opacity of the ApplicationBar to 0.99, so that the appbar comes above your ContentGrid.
Obviously you need to make some changes to your ContentGrid so that you can access the part of the Grid that the appbar is occupying.If your grid has ScrollViewer or ListView, it is always recommended to have some extra space after its contents*(may be a empty StackPanel with some height)* which will obviously solve this otherwise if it is a Static layout, you can make use of margin Property.

How a Slider control in WPF can snap on specific values?

I want to create a slider, with values from 0 to 100 that I can slide like any other slider... but at position 30, 42 and 55 (for example) I want to snap to these values, to make easy to the user to stop the slider at them
edit: my solution was to have 2 slider, the first one is invisible, value 0 to 200, and the other one is the visible on, value 0 to 100
The visible one cannot be slide, only the the invisible. Like this i can make a gap, ex: when I'm between 50 and 75 on the invisible slider, it's equals to 50 on the visible one...
You have to override OnValueChanged. See this article DiscreteSlider - Adding Functionality with a Simple Control Subclass and then this artice Silverlight slider control that snaps for a detailed explanation.
Instead of using SmallChange, you would check where between your values the slider sits and snap to the nearest.

WPF Clipping Problem

I have a UserControl which has a quadratic Image as a Child. This Image is at the bottom of the UserControl, and half of it is clipped (e.g. the Control's Height is 400, Image's height is 200 and it is set to y=300).
Now, When I rotate the Image, it is still clipped like the way it was first. Like when rotating around 90 degrees, I suddenly have an Image which is only 100px wide.
It seems like the original clipping which was made because of the bounds of the UserControl, are applied forever.
How do I solve this problem? I hope I explained my problem understandable ;)
How are you rotating the image? If you are rotating using a RenderTransform, then WPF does not re-render what was already displayed on the screen - it simply rotates the pixels.
Instead, rotate the image using a LayoutTransform; this forces WPF to re-render the control given the new area it occupies, which should eliminate the clipping you see.
You can also call InvalidateMeasure() after applying render transform.

WPF Canvas: centered origin, scaled axes (and y inverted), responding to mouse events

In a simple code-only WPF application I'm writing, I would like to have a custom Canvas.
I've found questions similar to this one here in StackOverflow, but couldn't find exactly this one, nor a simple way to adapt another answer to my specific problem (please note that I have not much experience in WPF).
In my canvas, I'd like it to have the following properties:
the point (0, 0) is on the center of the Canvas;
the x-axis points to the right;
the y-axis points to the top;
the point (1, 0) is about 1 inch to the right of the origin; and
in every event, the position of the mouse is given in the coordinate system defined above.
In this answer, Ray Burns propose a very simple solution to my first 3 points. It is trivial to modify that code so that it deals with my point number 4 as well (change 1 and -1 in the RenderTransform to other constants).
However, that very simple and excellent solution for many problems is based on setting width and height to 0, and centering the canvas on its container. Therefore, there's no canvas to capture events like a click, so this solution won't handle my fifth property.
What's the easiest way to achieve this? Inherit from Panel and do everything by hand? Inherit from Canvas, intercept every event and modify the coordinates?
Put Canvas inside a Border. Border has mouse events. Another case is to place Border on the top of the Canvas.

Resources