Binding a Source to a asynchronous method - xaml

Hello I have this following code
<controls:FlowListView x:Name="Board"
HasUnevenRows="true"
BackgroundColor="Black"
FlowColumnCount="3"
FlowItemTappedCommand="ExecuteAction">
<controls:FlowListView.FlowColumnTemplate>
<DataTemplate>
<StackLayout>
<Image VerticalOptions="FillAndExpand" Source="GetImageGivenCard"></Image>
</StackLayout>
</DataTemplate>
</controls:FlowListView.FlowColumnTemplate>
</controls:FlowListView>
This FlowListView ItemsSource will be a list of Cards. GetImageGivenCard would be a method which would acess a cache and retrieve an image given a designated card, all this asynchronously ofcourse (I'm using Akavache). Is what I'm trying to achieve possible ? If not, can you please give me some alternative solutions ?
Thank you for your time guys.
edit:
Source="GetImageGivenCard"
This line doesn't work ofcourse, it's only pseudocode for showing you what I would be hoping to obtain

Use https://github.com/luberda-molinet/FFImageLoading
It is a good plugin (caching, async, imageloader, placeholder included)

Related

How do I load an image from the Asset Catalog on cross-platform xamarin XAML?

It seems like a really easy thing to do, and in theory it looks very straight forward:
create the Asset Catalog
add an Image Set and name it "imageName" (without .png)
add the images
done
or at least that's what i read pretty much everywhere, but I still can't get it to work.
My XAML looks like this:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:CrossBaiscs"
x:Class="CrossBaiscs.MainPage">
<ContentPage.Content>
<StackLayout BackgroundColor="Orange">
<Label Text="Welcome to Xamarin.Forms!"
TextColor="White"
VerticalOptions="CenterAndExpand"
HorizontalOptions="CenterAndExpand" />
<Image VerticalOptions="CenterAndExpand"
HorizontalOptions="Center"
Source="logo1.png"/>
</StackLayout>
</ContentPage.Content>
</ContentPage>
And I added the images on the Asset Catalog:
I'm testing with Xamarin Live Player on an Iphone 6, and I can't see any image under the Label.
So... What am I missing?
EDIT
It works for this guy: Is it possible to use Image Set in a Xamarin Forms
But not for me, i did try removing the .png extension and leaving the xaml like this:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:CrossBaiscs"
x:Class="CrossBaiscs.MainPage">
<ContentPage.Content>
<StackLayout BackgroundColor="Orange">
<Label Text="Welcome to Xamarin.Forms!"
TextColor="White"
VerticalOptions="CenterAndExpand"
HorizontalOptions="CenterAndExpand" />
<Image VerticalOptions="CenterAndExpand"
HorizontalOptions="Center"
Source="logo1"/>
</StackLayout>
</ContentPage.Content>
</ContentPage>
Still doesn't work.
Tried cleaning build folders and deleting bin/obj folders, still nothing.
Tried adding the resources to the Resources folder and deleting the Image Set from the Asset Catalog:
Still didn't work.
Ideas?
EDIT 2
I left those 3 images on Resources folder and added the extension .png on XAML and it worked, still would be nice to know how its supposed to be done using the Asset Catalog.
Just to point out something that's probably obvious but caused me issues for ages - you can't use the LaunchImages set that comes with the asset catalog as it is not eligible to list in the Image dropdown. You have to create a new Image Set.
After I did this, the following answers suddenly worked (where they hadn't before):
Including the Asset Catalog folder in the project
Creating a storyboard that comes with a code-behind
don't use the .png extension in the XAML
<Image VerticalOptions="CenterAndExpand"
HorizontalOptions="Center"
Source="logo1"/>
In Xamarin Documentation they have clearly mentioned that- On iOS, the Page.Icon property can't be populated from an image in an asset catalog image set. Instead, load icon images for the Page.Icon property from the Resources folder in the iOS project.
We were testing on Xamarin Live Player on an IPhone, turns out Asset Catalogs are not yet supported. (https://twitter.com/praeclarum/status/941775333753217025?s=08)
Thanks for the replies!

Use <Interaction.Behaviors> and <EventTriggerBehavior> in UWP 10 app

How can I use <Interaction.Behaviors> and <EventTriggerBehavior> in a Windows 10 universal app? I will get something like this with Blend:
Source both images above: Jef Daels 2015
In may (bad) documentation, I've read that it must be something over here:
And here is the code for what I need to do it:
<ListBox Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="3"
ItemContainerStyle="{StaticResource lstidflt}" SelectedItem="{Binding SelectedVillage, Mode=TwoWay}"
ItemTemplate="{StaticResource weatheritemdt}" ItemsSource="{Binding VillageList}" >
</ListBox>
I've found it. I must install the 'behaviors' package from Nuget and than drag and drop it onto the element I need to use it. Thanks to ChrisW.!

Windows Phone 8.1 xaml - read language resources from external project

I have portable library in which I have AppLocalizations.resw resource files. I can read it in the code behind (which is obsolete, but working):
new Windows.ApplicationModel.Resources.ResourceLoader("Assembly/AppLocalizations")
But how can I use it from the xaml? When I try to read it this way, the text is blank, even if the key in the resource file is Key.Text
<TextBlock x:Uid="Key" />
I was triying to import it in the App.xaml, but with no success.
Thanks.
I use this code with Windows Phone Universal Apps, but with a general resources:
<TextBlock Style="{StaticResource TextBlock_BlackStyle}" x:Uid="/Resources/txtIPName" Name="txtIPName" HorizontalAlignment="Left" Margin="33,149,0,0" TextWrapping="Wrap" Text="IP:" VerticalAlignment="Top"/>
Then if u had exertanl library, I think the code is:
<TextBlock x:Uid="/Assembly/AppLocalizations/Key" />
Tell me if I solve your problem! Good luck man! :)

Modifying FullScreen Design for ListPicker

I've Been working with WP7 for a while, am using listPicker/DatePicker Heavily. i hate its design though.i use liskPicker's property ExpansionMode="FullScreenOnly". i tried to make those controls to look prettier by
// Setting A source to the FullModeItemTemplate
FullModeItemTemplate="{StaticResource lpkFullItemTemplate}"
//the definition for this Resource is as follows:
<DataTemplate x:Name="lpkFullItemTemplate">
<StackPanel Orientation="Horizontal" Margin="5 5 5 5" Background="#FFA3A3A3"
Width="475" Height="45" >
<TextBlock Text="{Binding}" Foreground="Black" Margin="5 5 15 5" />
</StackPanel>
</DataTemplate>
I need real changes, changing the background of that popup and such changes, is that possible? or i need to build my own popup from scratch?
In order to do that you will have to create a copy of the ListPickerPage.xaml file from the Silverlight for Windows Phone Toolkit in your application, change it to meet your requirements, and then on your ListPicker control set the PickerPageUri proprety to the new ListPickerPage.xaml
I would like to improve Pedro's answer, but I still can't comment. You can see there's some people making questions up there.
In order to copy the ListPickerPage you'll need both the ListPickerPage.xaml and ListPickerPage.xaml.cs files. If you want those files to compile, you need some extension methods defined on Extensions.cs, ItemsControlExtensions.cs and VisualTreeExtensions.cs. You can either copy those three files or cherry pick the methods you need and add them to your own file.

Silverlight 5: Set ConstructorArgument on a IMarkupExtension class

I would like to have a MarkupExtension that can be initiated with just one value, much like Binding:
<TextBox Text="{Binding MyPath}"/> instead of <TextBox Text="{Binding Path=MyPath}">
In WPF this is done with the ConstructorArgumentAttribute, but this doesn't exist in Silverlight.
I checked for attributes on the Path property of Binding but have'nt found any attributes applied to it.
Any ideas?
For now I realize that it's not yet implemented.
So if you think this feature is compelling, please go ahead and vote for this feature here.
Hope this answer to be updated as soon as I have any piece of news (hope this to happen asap...).