Click here to Skip to main content
15,949,686 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
xaml code
--------
<listview name="AddonListView"> Grid.Row="1"
Height="430"
BorderThickness="0"
ScrollViewer.VerticalScrollBarVisibility="Visible"
ScrollViewer.VerticalScrollMode="Enabled"
removed="Black"
CanDragItems="True"
CanReorderItems="False"
IsItemClickEnabled="True"
ItemClick="AddonListView_ItemClick_1"
SelectionChanged="AddonListView_SelectionChanged_1">
<listview.itemtemplate> <datatemplate>
<Image Margin="10"
Width="200"
Height="200"
Source="{Binding AddonImagepath}" />
</Image.Source>
</Image>-->


c# code
-------
Image addon = new Image();
addon.Name = "PART_Addon_" + System.DateTime.Now;
addon.SetValue(Canvas.TopProperty, 0);
addon.SetValue(Canvas.LeftProperty, 0);
addon.SetValue(Canvas.ZIndexProperty, 0);
addon.Stretch = Stretch.Uniform;
var bitmap = new BitmapImage(new Uri(imagePath)) ;



==========
i am getting error

Invalid URI: The format of the URI could not be determined.
Posted
Comments
Sergey Alexandrovich Kryukov 21-Nov-13 1:31am    
And what is the example of this URI? What is the ImagePath value?
—SA

1 solution

You need to look at the value in imagePath - it should contain a valid absolute URI.
If you look at MSDN: Constructor: URI(string)[^] it lists all the reasons it can throw the exception:
uriString is empty.
-or-
The scheme specified in uriString is not correctly formed. See CheckSchemeName.
-or-
uriString contains too many slashes.
-or-
The password specified in uriString is not valid.
-or-
The host name specified in uriString is not valid.
-or-
The file name specified in uriString is not valid.
-or-
The user name specified in uriString is not valid.
-or-
The host or authority name specified in uriString cannot be terminated by backslashes.
-or-
The port number specified in uriString is not valid or cannot be parsed.
-or-
The length of uriString exceeds 65519 characters.
-or-
The length of the scheme specified in uriString exceeds 1023 characters.
-or-
There is an invalid character sequence in uriString.
-or-
The MS-DOS path specified in uriString must start with c:\\.

Without access to the variable content, we can't tell you which is causing the problem. Either use the debugger to put a breakpoint on the line:
C#
var bitmap = new BitmapImage(new Uri(imagePath)) ;
And manually examine the content, or log the content to a file before you execute the line and look at it later.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900