Data binding the Image control in Windows 8 to a URL? - image

In Windows 8/Store programming, how would you go about databinding an image to a URL. In other platforms I've worked with, I would set the source property (or equivalent) to the URL and the platform would handle it for me, but that doesn't seem to be the case here.
I'm currently binding it to a property for my business object that is of type "string", and returns the URL of the image that I want populated in the image control. How would I go about doing this?

Turns out this is really easy.
Code:
<Image Stretch="UniformToFill">
<Image.Source>
<BitmapImage UriSource="{Binding Path=ImageUrl}" />
</Image.Source>
</Image>
ImageUrl is a Uri containing the path to the remote image.

Related

Lottie error:"Java.Lang.IllegalStateException: 'Unable to parse composition'"

When i tried to load gif to my project suddenly return me error:
Java.Lang.IllegalStateException: 'Unable to parse composition'
Image for more information link
I want to insert gif to my project I tried to use Lottie and Json File
My code so far
<forms:AnimationView
x:Name="animationView"
Grid.Row="1"
Animation="first.json"
Loop="false"
AutoPlay="false"/>
Please add xmlns:lottie="clr-namespace:Lottie.Forms;assembly=Lottie.Forms" to your XAML head and use this component
<lottie:AnimationView
x:Name="AnimationView"
Animation="first.json"
AutoPlay="True" Loop="true"
VerticalOptions="FillAndExpand"
HorizontalOptions="FillAndExpand" />
and dont forget to init AnimationViewRenderer.Init(); on MainActivity and AppDelegate
In my case i replaced app:lottie_url with app:lottie_rawRes , and it worked just fine
need determine json like
Android: DroidProject/Assets/filename.json like AndroidAsset
iOS: iOSProject/filename.json like BundleResource
This error occurred when lottie.setAnimation(""); is not set or blank

App displays URL images from other URLs than my own

I am unable to make the URL public, but I've pasted the full URL into my browser and can confirm the page is right - the image shows in the browser.
But... when I copy that exact URL into a Xamarin.Forms image, set as:
<Image
HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand"
Aspect="AspectFit">
<Image.Source>
<UriImageSource Uri="https://example.com/images/doesntshow.jpg"
CacheValidity="3"
CachingEnabled="false"/>
</Image.Source>
</Image>
The image simply will not show.
If I substitute the URL: "https://upload.wikimedia.org/wikipedia/en/a/a9/Example.jpg" the image shows fine.
NOTE: There is 0 possibility the URL is incorrect or has an error because... I'm not typing it; I'm copying/pasting it and it's showing just fine in the browser, just not the Xamarin.Forms app.
I've not a clue as to what to look for. Does anyone else?
ISSUE RESOLVED - thanks for the good mental vibes :)
I found the resolution here:
https://forums.xamarin.com/discussion/105036/images-from-url-not-showing-on-android
April 5
"Just change the following options and it should work with https too.
Android Options => Advanced
HttpClient implementation = Set to "Managed" option value
SSL/TLS implementation = set to "Native TLS 1.2+" option value"
I still don't understand why prior to this setting change, I could load https images from other servers just fine (e.g. "https://upload.wikimedia.org/wikipedia/en/a/a9/Example.jpg"). So... I will lose a bit of sleep wondering what is different on my server from wiki's. If you have a clue, please share.

React Native Image Not Working with specific URL

I have the following code below, where the Image component encompasses two Image component.
<View style={styles.container} >
<Image
style={{width: 50, height: 50}}
source={{uri: 'https://facebook.github.io/react/img/logo_og.png'}}
/>
<Image
style={{width: 50, height: 50}}
source={{uri: 'http://lghttp.24811.nexcesscdn.net/80B00B/qpb/media/catalog/product/cache/11/image/439x334/9df78eab33525d08d6e5fb8d27136e95/q/w/qw_neverdonejoggers_p_.png'}}
/>
</View>
For the first github URL it renders the img logo correctly as expected.
However for the second Image it doesn't render the source: qw_neverdonejoggers_p_.png
Which leads me to the conclusion that something wrong URL, however clicking on the URL correctly load the Img:
http://lghttp.24811.nexcesscdn.net/80B00B/qpb/media/catalog/product/cache/11/image/439x334/9df78eab33525d08d6e5fb8d27136e95/q/w/qw_neverdonejoggers_p_.png
I attempted to replicate the issue here, https://rnplay.org/apps/_dQXXw
but it renders both the images properly.
So its only on the local my computer that for some reason I can render second image ?
Using:
"react": "15.4.1",
"react-native": "^0.39.2",
Andrés' answer is somewhat correct, but it does not address the exact cause of the problem, and that is iOS' App Transport Security. iOS does not allow plaintext requests (http) by default, and so you need to define a 'whitelist' of URLs that can be allowed to override this particular protection mechanism. You have that list already set up so that your app can connect to localhost during development,, so just add new entries to it. You can see how to do so in this answer. Of course, this only works if you know the list of URLs in advance, which might not suit your needs. In that case, have a look at this article.
uri only works with https. In Android it should work fine with either http or https.
You will find further information here.
Guys there is an issue with Image component is that if first time initialize the component with source={{uri : 'some link'}} it may not work (at least not for me when I fetch image from HTTPS URL from Firebase storage). The trick is you have to trigger a change to source props like first you need to keep
source to source={undefined} and then change to source={{uri : 'some link'}}.
Hope it would help someone
Aside issue with HTTPS, make sure you set the width and height of the Image
How i make Image source with http or https url work is by resetting the android emulator am using.
You can clear the emulator by opening the android studio then click on tools tab at the top bar select AVD Manager once it open
Select the emulator you are using, right click on it then select wipe data.
Once that process is completed, open cmd or terminal at the root of your react-native project
$ npx react-native run-android

x:Type in Windows Phone App

In a WPF Application I can use x:Type, e.g. for ConverterParameter:
<TextBlock Text="{Binding SelectedParty.Firstname}" Visibility="{Binding SelectedParty,Converter={StaticResource TypeToVisibilityConverter}, ConverterParameter={x:Type model:PersonParty}}"/>
In a Windows Phone 8 App "x:Type" is unavailable! How can I pass a type?
Thanks!
You could just pass the object as the parameter and then determine it's type in the converter.
This would therefore mean you're creating a "PartyToVisibility" converter but just basing the logic on the type of the party.

How can I get MP3 flux with Windows Phone 7?

I tried this code, but it didn't work:
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<MediaElement Height="120"
HorizontalAlignment="Left"
Margin="-12,148,0,0"
Name="mediaPlayer"
VerticalAlignment="Top"
Width="474"
AutoPlay="True"
/>
</Grid>
C#:
Uri Path = new Uri("http://streaming.acc.net:8000/kalilo");
mediaPlayer.Source = Path;
Looks like you're using a unsupported type of stream. And since your link isn't valid, that's all the info we can provide.
Remember that you can't play music in the emulator, and on the device you need to use WPConnect.exe to connect instead of Zune, to make it actually play.
If that is a streaming service, MediaElement is a basic, but often unreliable source because of possible interruptions (e.g. switching from WiFi to a cell data connection). It works in most situations, but it has restrictions on media content that is passed through it.
Assuming that the URI you are showing belongs to a Shoutcast stream, it is not supported by default and you need to implement a connector through MediaStreamSource, even if you receive MP3 bytes.
Here is a great MediaStreamSource example from Tim Heuer.
Also worth checking out - ManagedMediaHelpers.

Resources