Is it possible to put a image into a control in WinRT and then let the user zoom in and out etc?
Yes!
The easiest possible way is to put it inside a scrollviewer. You can zoom in and out whatever you like that way!
<ScrollViewer MaxZoomFactor="3"
MinZoomFactor="0.5"
ZoomMode="Enabled">
<Image Source="/Assets/logo.png" Width="200" Height="200"/>
</ScrollViewer>
Related
I am using VS2013, Windows 8.1 and developing a windows store app.
Im creating a simple contacts - listview, that displays the contact details along with contact image within an ellipse. When I click on the listview item, I want to display the contact details on right side of the page. Now the issue I am facing is, I am not able to fit the contact image to the right size on the ellipse on the right side pane.
I am able to achieve it in my list view since its an smaller ellipse.
Important: I do not want the image to look stretched/Zoomed in /Zoomed out. It should exactly look like how it appears within the list view. (For list view , I have used Ellipse.Fill along with Imagebrush, but relatively smaller sized ellipse)
What I tried so far:
Ellipse.Fill property which paints the image to size, but the image looks stretched.
I tried setting "Stretch" property within the image tag within ellipse, but did not work.
I tried Image.clip, but I do not have "EllipseGeometry" option, instead only RectangleGeometry.
Lastly I created an image that has a transparent center and I place this frame over the contact image like a mask. This works well on some resolutions. But when some other resolution, the contact images which are binded from backend, go beyond the frame, although I set "MaxHeight" or "Height" properties.
I want to do it the right way, since I feel adding an image mask might not be a great way to achieve this. Please help!
I tried this for listview, n works fine, But the same code for right pane looks stretched (I have tried removing stretch attirbute, or tried other options like Stretch ="None" /"Uniform" etc )
I have attached screenshot.
Since code isn't clearly mentioned, you can do it with both Ellipse and Border. Here's the code snippet
<!--With Ellipse-->
<Ellipse Height="200"
Width="200">
<Ellipse.Fill>
<ImageBrush Stretch="Uniform"
ImageSource="Assets/profile.png" />
</Ellipse.Fill>
</Ellipse>
<!--With Border-->
<Border Height="200"
Width="200"
CornerRadius="150">
<Border.Background>
<ImageBrush Stretch="Uniform"
ImageSource="Assets/profile.png" />
</Border.Background>
</Border>
Here's the result
The properties "AlignmentX AlignmentY" within ImageBrush solved my issue.
If your image has portrait orientation, then you can use Stretch, AlignmentX, AlignmentY properties of ImageBrush like this to achieve best preview result
<Border CornerRadius="20" BorderThickness="1" BorderBrush="DarkGoldenrod">
<Ellipse Width="40" Height="40">
<Ellipse.Fill>
<ImageBrush ImageSource="{Binding PractitionerPhoto}" Stretch="UniformToFill" AlignmentX="Center" AlignmentY="Top" />
</Ellipse.Fill>
</Ellipse>
</Border>
Good day, I want to have my canvas have rounded corners. i know you place the canvas inside a Border Tag and round from there like
<Border>
<Canvas>
</Canvas>
</Border>
Now the solutions i have seen, they have an element in their Xaml called ClipToBounds Which makes the canvas adjust to the border but it is not present for SilverLight. so is there a way i can have this feature or an alternative so that the Canvas clips correctly to the Border? Thanks in Advance.
P.S i know i can set the canvas to transparent and the border background to the background i want the canvas to take, but am still learning windows phone so am trying to know as much solutions as possible in case that always doesn't work. Thank you
You can use Canvas.Clip:
<Canvas Height="100" Width="100" Background="white">
<Canvas.Clip>
<EllipseGeometry Center="50, 50" RadiusX="68" RadiusY="68" />
</Canvas.Clip>
</Canvas>
Also, here's a handy tutorial if you wish to define your own ClipToBounds behaviour:
http://www.codeproject.com/Articles/36495/Silverlight-ClipToBounds-Can-I-Clip-It-Yes-You-Can
I am working at a WinRT application that implies some manipulations of an image at a WriteableBitmap level. On my page, I have ofcourse an image that shows the processing results. My objective now, is slightly different though, I would like to know if there is any way I could acces through code the built-in zoom in/out that could be achieved through pinch mode if on touch device on control + mouse wheel if on PC.
Here's a bit of my code where I've got the image :
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
<Image Grid.Row="0" x:Name="ImagePanel" Stretch="Uniform" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</ScrollViewer>
I am asking this in case anyone might know if this can be achieved only because the zoom is very optimized and can be extremely useful :)
Thank you, any help or suggestions are greatly appreciated.
The ScrollViewer has a ZoomFactor property and a ZoomToFactor() method you can use.
Is it possible to add a background image to an AdControl? Or is it possible to place an AdControl over an image and give it a transparent background?
I have been trying several things to try to accomplish this - no luck so far.
You can try putting a AdControl inside a Border Control. You can set the Image to a Border Control.
<Border Background="Red">
<AdControl id="adControl1" height=80 width="480" />
</Border>
Most of the Ads have a Transparent Background.
Hope this helps.
I am developing Windows phone 7 application, I need to do a slide show like application. I have the File[] when I swiping left or right the previous or next Image should show. how to Do it? I think it is possible through Manipulation events. but how to do this , I dont know Can u explain this?
The simplest way to create this effect woudl be something like this:
<ScrollViewer HorizontalScrollBarVisibility="Visible">
<StackPanel Orientation="Horizontal">
<Image Source="A.png" />
<Image Source="B.png" />
<Image Source="C.png" />
<Image Source="D.png" />
</StackPanel>
</ScrollViewer>
Although you could add the images through code.
If you want something more complex in your animation or need control over how an image can be interacted with you may want to do something different.
Before trying to use manipulations you may be able to use the Flick event from the toolkit which may make what you're trying to achieve easier.
It will all depend on what you're trying to do. Your question isn't explicitly clear.
See also how to get swipe in windows phone 7