Getting out of memory exception while loading image using 'FFImageLoading.CachedImage' in xamrinform - xamarin

I want to show list of images in single page as like gallery. In my xaml page I am creating single wrap view, in that wrap view I have
add ffimageloader for loading images. Here I have gave list of image url' to that wrap view contain ffimageloader. When I called that page it shows fallowing error.
system.outofmemoryexception: out of memory at ffimageloading.platformimageloadertask..... like that. many post's suggest if we using ffimageloader instead of image tag we will reduce this type of issues but still getting same issues after using this one also. I am running my application in xamarin android. Please suggest any idea.
Here is the sample code what I have tried
<CustomWrapView x:Name="SampleGalleryView" ItemsSource="{Binding GalleryImages}">
<CustomWrapView.ItemTemplate>
<DataTemplate>
<ffimageloading:CachedImage Source="{Binding ImageUrl}" />
</DataTemplate>
</CustomWrapView.ItemTemplate>
</CustomWrapView>

Take a look at FFImageLoading's downsampling capabilities. You can read more about it here: https://github.com/luberda-molinet/FFImageLoading/wiki/Xamarin.Forms-API#downsampling-properties
If you have a lot of items, you should use some view which is capable of doing items virtualisation (I suspect that WrapView isn't), like: ListView / CarouselView, etc

Related

How to create LibVLCSharp custom playback controls in Xamarin Forms?

I've been searching for days now for a guide on how to create the custom playback controls for LibVLCSharp that everyone seems to talk about, which I never found a guid for.
I simply want to create other buttons with event handlers for the bottom playback control panel, I tried this but throws a System.NullReferenceException exception on startup while getting into break mode...
<vlc:MediaPlayerElement MediaPlayer="{Binding MediaPlayer}" LibVLC="{Binding LibVLC}">
<vlc:MediaPlayerElement.PlaybackControls>
<vlc:PlaybackControls>
<vlc:PlaybackControls.ControlTemplate>
<ControlTemplate>
<Grid>
<StackLayout Orientation="Horizontal" HorizontalOptions="CenterAndExpand">
<Button Grid.Column="0" Text="Test 1"/>
<Button Grid.Column="1" Text="Test 1"/>
<Button Grid.Column="2" Text="Test 1"/>
</StackLayout>
</Grid>
</ControlTemplate>
</vlc:PlaybackControls.ControlTemplate>
</vlc:PlaybackControls>
</vlc:MediaPlayerElement.PlaybackControls>
</vlc:MediaPlayerElement>
I want it to act just like the original one (Auto hides, overlays on tapping, etc...) but with my own layout and controls. I also thought about using the existing one and try to override their handler to implement my own code and override the text property for each button to change its icon but no luck of finding any help.
Thanks in advance ^_^
The code you are interested in is here: https://code.videolan.org/videolan/LibVLCSharp/-/blob/3.x/src/LibVLCSharp.Forms/Shared/Themes/Generic.xaml
I also thought about using the existing one and try to override their handler to implement my own code and override the text property for each button to change its icon
That'd be the way to go.
This previous SO question might answer your question: https://stackoverflow.com/a/14217500/4064749
Just create a new Style based on PlaybackControlsStyle, override what you want and then set it on the PlaybackControls element.
I created https://code.videolan.org/videolan/LibVLCSharp/-/issues/309 recently to track the need of a tutorial to customize the MediaElement.
Further docs on style inheritance: https://learn.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/styles/xaml/inheritance
I finally found the problem which was making exceptions, when I create custom control template which completely correct, the MediaPlayerElement code behind by LibVLCSharp developers itself cannot find the elements with the names defined anymore as they used hardcoded names for the buttons and views instead of using bindings and dynamic setters.
Thus, several workarounds could be made to fix such issue, here are some of my ideas:
Use the generic style documented here and modify it without removing any elements but rather hide them out or overlay them.
Create your own style with controls obtaining the same names of the original ones.
Find a way to modify or maybe create a whole new playback control element using the original one which can be found here and here.
Thanks to mfkl's answer which helped me find out how everything worked under the hood to come up with the explaination, even though this took me a couple of days to figure out.

Showing multiple images one by one in WP7?

Which control is suitable for showing the images one by one like photo gallery in WP7?
The MetroFlow tool from the Coding4Fun Toolkit will help you accomplish that:
http://www.windowsphonegeek.com/articles/Getting-Started-with-the-Coding4Fun-toolkit-MetroFlow-Control
It really depends on how you want to stack them and where you are getting them from. For example, you could use a ListBox with a custom DataTemplate. Or you could use a StackPanel or a WrapPanel from the Silverlight Toolkit.
How about Telerik's RadSlideView control?
http://www.telerik.com/products/windows-phone/overview/all-controls.aspx#slideview
If the images are small just use StackPanel:
<StackPanel>
<Image ... />
<Image ... />
</StackPanel>
You can use ListBox as well (you will get Scrolling and Virtualization out of a box):
<ListBox>
<Image ... />
<Image ... />
</ListBox>
What I have done, is use the wrap panel control to display the thumbnails of the images in a grid, then when selecting an image, I navigate to a generic page with pretty much just a data bound pivot control with the source bound to my collection of photos. You can set the index of the pivot to whatever the index of the selected photo is in your collection and then swipe between the photos.

Windows Phone 7 Databinding Outside Attributes (Nonstatic Hyperlink text)

I currently have a listBox in a WP7 application that uses databinding to populate it. The problem I'm having though is with this particular line:
<Hyperlink NavigateUri="{Binding LinkUrl}" TargetName="_blank">{Binding Name}</Hyperlink>
It seems that I can't bind things in this way (outside of an element's attributes). All this does is create a hyperlink with the literal text {Binding Name} linked to the url. Instead what I'm looking for is for it to use the actual Name variable in its place.
I've tried googling for an answer and looked into the Inlines attribute, but I keep coming up empty handed.
Any help would be appreciated
In WPF, the space between the tags is usually the 'content' (but not always) and bindable via the Content property. I'm unfamiliar with <Hyperlink> in Windows Phone, but a <HyperlinkButton> should work just as well.
<HyperlinkButton NavigateUri="{Binding LinkUrl}" TargetName="_blank" Content="{Binding Name}"/>
EDIT: For a <Hyperlink> in a <RichTextBox> try this:
<RichTextBox>
<Paragraph>
<Hyperlink>
<Hyperlink.Inlines>
<Run Text="{Binding Name}"/>
</Hyperlink.Inlines>
</Hyperlink>
</Paragraph>
</RichTextBox>

Bing map on WP7

How can i display a list of positions (from a xml document:using xml reading) in a Bing map with WP7? The idea is similar to Foursquare.
Microsoft wrote a good throughout tutorial on the subject, that also explains how to use databinding, so you can do proper code and view seperation.
It all relies on instances of Pushpin that are placed on a map layer. You can see a short working sample here.
The tutorial linked by Claus nicely points out how you can use Pushpins on a BingMapsControl. If you take out the essence of the tutorial this is the piece of code you want to use. All you need is a collection of items with at least a Location attribute. If you want your Pushpin to have a label you can also add a Name attribute.
You can databind the collection of items to your mapcontrol by adding this piece of code within your BingMapsControl.
<maps:MapItemsControl ItemsSource="{Binding Items}" >
<maps:MapItemsControl.ItemTemplate>
<DataTemplate>
<maps:Pushpin Content="{Binding Name}" Location="{Binding Location}"/>
</DataTemplate>
</maps:MapItemsControl.ItemTemplate>
</maps:MapItemsControl>
If you need any more explanation please refer to the tutorial mentioned by Claus

Generating and displaying images in grid in Silverlight

I want to develop an webpage like Google Images in Silverlight.
The difference is the images are generated from my DSL.
The webpage shows different images in grid and allows users to pick one.
The webpage then shows similar images to this.
Should I use Grid panel or DataGrid? And how do I handle double click on cells?
Should I generate my DSL to Shapes or Image? What are the pros and cons?
Thanks.
This is actually pretty simple, all you need to do is use a data template for the column in your datagrid.
<sdk:DataGrid.Columns>
<sdk:DataGridTemplateColumn Width="80">
<sdk:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Image Width="240" Height="180" Source="http://www.yourimage.com/images/myimage.png" />
</DataTemplate>
</sdk:DataGridTemplateColumn.CellTemplate>
</sdk:DataGridTemplateColumn>
</sdk:DataGrid.Columns>
Optional: If you need to change the image via code rather than inline like this then in place of the Image XAML element put a stackpanel that calls a function in your code-behind, which returns an image.
<StackPanel Loaded="StackPanel_Loaded"></StackPanel>

Resources