Crop image in windows phone 8 - windows-phone-8

I try to crop image in windows phone 8 App.
I use following namespace
xmlns:y="clr-namespace:System.Windows.Media.Imaging;assembly=Microsoft.Phone"
And write content panel like this.
<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<Image HorizontalAlignment="Left" Height="200" Margin="97,153,0,0" VerticalAlignment="Top" Width="200">
<Image.Source>
<y:CroppedBitmap
SourceRect="30 0 75 50">
<y:CroppedBitmap.Source>
<BitmapImage UriSource="/Assets/image.jpg"/>
</y:CroppedBitmap.Source>
</y:CroppedBitmap>
</Image.Source>
</Image>
</Grid>
Error is occurred.
error : The tag 'CroppedBitmap' does not exist in XML namespace 'clr-namespace:System.Windows.Media.Imaging;assembly=Microsoft.Phone'.
If anyone can solve this or do this using another way. please help me.

Use WriteableBitmapExtension library instead which has inbuilt crop functionality.
http://writeablebitmapex.codeplex.com/

Related

What's wrong with Windows Phone 8.1 Pivot? (WinRT - not Silverlight)

So I've decided to migrate from Windows Phone 8.0 to Windows Phone 8.1 API - not the silverlight one.
The reason was that I wanted to use Win2D drawing library which is not supported for Silverlight 8.1 or WP 8.0
The weird things are happening.
Simple Pivot view is incredibly laggy and also it is not displaying views properly.
I am using latest Visual Studio 2015. On the video I linked you can see the result of following Page XAML code (just for testing):
<Page
x:Class="Apptest2.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Apptest2"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel Grid.Column="0">
<Button Content="Go"
/>
</StackPanel>
<Pivot Grid.Row="1"
x:Name="PivotView"
Margin="10,0,10,15"
CacheMode="BitmapCache"
VerticalContentAlignment="Stretch">
<PivotItem Header="item1">
<Grid Background="BlueViolet" />
</PivotItem>
<PivotItem Header="item2">
<Grid Background="BlueViolet" />
</PivotItem>
<PivotItem Header="item3">
<Grid Background="BlueViolet" />
</PivotItem>
<PivotItem Header="item4">
<Grid Background="BlueViolet" />
</PivotItem>
<PivotItem Header="item5">
<Grid Background="BlueViolet" />
</PivotItem>
<PivotItem Header="item6">
<Grid Background="BlueViolet" />
</PivotItem>
</Pivot>
</Grid>
</Page>
Is anyone able to tell what is going on here? Should I use some pivot analogs from 3rd parties or maybe just forget about using it in new os?
Pulling my hair out.
Any solution would be hugely appreciated!
Link to video
The problem is you are using CacheMode="BitmapCache" on your Pivot. Remove this line and the performance should be good after.
First of all the caching is applied to the element and all of it’s child elements and BitmapCaching should be used in scenarios where you are blending, transforming (translating, stretching, rotating). If you need BitmapCaching then try not to use it on root controls, use it on the children that really need BitmapCaching.
Misuse of the CacheMode feature can hurt performance, so you need to really think through what you are doing. If your visual tree is interleaving cached and un-cached elements, you are effectively causing multiple rendering surfaces to get created behind the scenes. The un-cached surfaces are rendered in software and the cached surfaces are rendered in hardware. Your performance will be best if you can minimize the total number of rendering surfaces and get the hardware to do work where it can.
Reference from another StackOverflow answer. I hope it helps.

Windows Phone 8.1 scrolling image gallery

I'm creating an image gallery that users can view by swiping an image to the left or right (horizontally) to see the next (or previous) image. Ideally, the image would snap into place like a hub section. I don't want to use a hub, however, due to memory concerns, as well as a hub isn't meant for this purpose.
I'm getting the first image to load, but I cannot swipe or move to another image in the collection. The first image loads, and I cannot slide it left or right.
Any help or suggestions would be appreciated.
Here's my relevant code:
ViewModel
Images = (await _service.GetImages(sectionId))
.Where(i => "Image".Equals(i.Type))
.SelectMany(sr => sr.Images
.Where(ii => "Standard Resolution".Equals(ii.Type))
.ToList();
(This above code successfully returns a list of image objects.)
XAML
<Grid x:Name="ImagesLayout" Grid.Row="1" Height="250">
<ListBox ScrollViewer.HorizontalScrollBarVisibility="Visible"
ItemsSource="{Binding Images}">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<Image Source="{Binding Url}" Stretch="Fill" />
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
Here's a good article that outlines exactly how to implement an image carousel for Windows Phone 8.1. http://www.captechconsulting.com/blogs/windows-81-image-carousel

WP8 webview missing reference

Im trying to add webview inside xaml. It gives this error. I ve searched but couldnt find the answer. Is it possible to add webview inside WP8 page.
<Grid x:Name="todaysGrid" >
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<WebView x:Name="webView1" Grid.Row="0" Height="800"/>
</Grid>
Error 1 The type or namespace name 'WebView' could not be found (are you missing a using directive or an assembly reference?)
Thanks.
The control is called WebBrowser.

How to convert HTML codes to XAML in Windows Phone

I am creating Windows Phone Application, I am getting HTML codes from web service response,
like
" ,<br>"
how do I convert them in xaml?
is there any static method available?
because I have tried HttpUtility mehtod but not getting the converted result
There is no built-in functionality to do this. You'll need to manually map the content to a <RichTextBox /> and insert the necessary <Paragraph /> and <Run /> elements as necessary.
Maybe you could use this HTML to XAML FlowDocument converter: http://blogs.msdn.com/b/wpfsdk/archive/2006/05/25/606317.aspx
Then you could use a custom control, here's an example:
<ControlTemplate TargetType="{x:Type local:ReplyBoxControl}">
<Border BorderBrush="Black" BorderThickness="1" Background="#F0E0D6" MaxHeight="320" Width="300">
<FlowDocumentScrollViewer VerticalScrollBarVisibility="Auto" MaxHeight="320" Height="Auto"
Document="{TemplateBinding TestText2, Converter={StaticResource HtmlToFlowDocumentConverter}}" />
</Border>
</ControlTemplate>

how to swap images like only one image display in one page,next image in next page just like windows phone gallery,in windows phone 8

I am new to windows phone 8 development so any one can you please help me in getting the Original size images which is stored into the camera roll (sdcard) in windows phone. and how to swap images like only one image display in one page,next image in next page just like windows phone gallery.I want to develop app that capture images fro camera roll,but all images display same size here i use listbox & scrollviewer(can you provide simple code for this)
You should use Pivot Control and in its content load the image
<phone:Pivot x:Name="PivotAttachment"
ItemsSource="{Binding ObsDownloadedAttachments}" Foreground="Black" FontSize="48">
<phone:Pivot.ItemTemplate>
<DataTemplate>
<Image Grid.Row="1" Source="{Binding DownloadedBitmap}" />
</DataTemplate>
</phone:Pivot.ItemTemplate>
<phone:Pivot.HeaderTemplate>
<DataTemplate>
<TextBlock Text="{Binding ImageUrl}"
Foreground="{Binding Converter={StaticResource ThemeColorBrushConverter}}" />
</DataTemplate>
</phone:Pivot.HeaderTemplate>
<!--Pivot item one-->
<!--Pivot item two-->
</phone:Pivot>