WPF Image Overlay - wpf

I have an <Image /> used in a ControlTemplate to show a 24 bit PNG. Ontop of this, I'd like to apply a semi-transparent gray layer to make it appear half disabled. The problem I'm having is that if I just apply a gray layer, the transparent parts of the image just change to gray, instead of staying transparent and only applying to the coloured parts.

You could set the Opacity of the Image instead.

Related

Crop WPF control

I have to crop some control to show only a half of it but the rest should be transparent and clickable so it is not enough to cover the control with something. The result should give a control with only half of the content (for example 50% of top) and the rest should be cropped (not hidden) so some other control below should be visible and not overlapped by cropped part. New control should also scale when window is scaled. How to do this in WPF?
I have finally did the trick using Border around the control and Clip property of this border was set to Multibinging that was generating Rectangle basing on ActualWidth and ActualHeight of my control
Maybe GridSplitter:
http://www.wpf-tutorial.com/panels/gridsplitter/
Can be used to split views horizontally/vertically, and can be responsive.

Canvas background color not as white as I need

I am setting the background color of my Canvas as 'white'. However when I compare my canvas with a vendor application, their canvas is 'whiter', which is the color I want for my canvas too. I have looked at all the color choices available for canvas background color but nothing makes my canvas any whiter than it is. Any suggestions would be appreciated.
Simple solution:
Use one of the browser plugins to get the actual "white" color of their app.
One example of a color-picker is Chrome plus the ColorZilla extension:
https://chrome.google.com/webstore/detail/colorzilla/bhlhnicpbhignbdhedgjhgdocnmhomnp

How do i create xaml (silverlight) animation like attacted image?

I want to create animation like this image, i'm wondering how do i get start for this ? in silverlight xaml
this bar will increased or decreased in animation
thanks for any help
I would create image overlay to create grid effect and would draw solid rectangles under the image. Animate rectangles using standard XAML animations.
Or even better: animate black overlay rectangles covering top of bars.
Sent from windows phone.

How can you use an ImageBrush to display a specified area of an image as the background of a rectangle?

I'm trying to add a zoom feature for an image viewer control I'm creating. When viewing the image, holding down the left mouse button brings up a rounded rectangle that is zoomed into the image. I figure I can use An ImageBrush as the background but I can't figure out how to make it just display a specified area of the image. Can this even be done?
By using the Viewbox.

How can I change the color of an image in silverlight/WP7 (Color Mask)?

I have a toggle button with a png that has a transparent background and a black foreground. If the button is selected then I want the black color of the image to change to a color chosen by the user. Is there a way to do this in Silverlight and/or wp7?
So for example:
<ToggleButton>
<Image Source="MyImage.png" />
</ToggleButton>
MyImage.png has a transparent background and a black foreground. The user's preferred color is red. When the button is toggled on I want the black foreground of the image to turn red.
I would try OpacityMask approach. Basicaly it should look something like this:
<Rectangle Fill="Red">
<Rectangle.OpacityMask>
<ImageBrush ImageSource="MyImage.png"/>
</Rectangle.OpacityMask>
</Rectangle>
by changing rectangle's fill property you would get different colored image.
How much control does the user have over the colour?
If they are picking from a limited set (e.g. red, green, blue, black, brown) then the simplest thing to do would be to bind the image source to a variable which holds the name of the image and then change which name is held in that variable.
If they can pick any colour then you need to do some image processing to change the black pixels of a reference image to the selected colour, write that to isolated storage and then bind the image source to that new file.
Another alternative is to draw the button in XAML and then you can have direct control over the foreground colour. This MSDN page describes the basics of drawing. You can use the same commands to define the image on a button, as described on this page from Scott Gu's blog:
(this is the image of the code from the blog).
If you bind the colour to a variable then the user can change the colour of the image. It does rely on you being able to draw the image in XAML though.

Resources