how to set relative image path of image source from style
-
Hi All, I have one image control, Currently I am setting the image path as absolute. Since the image is at the server side where the Silverlight application is hosted.The source set as follows: <Image x:Name="imgMyImage" Source="http://localhost/MyImage.JPG" > I want to set the relative source from the server in the style. I followed following link and I succeed giving the relative path from the Image tag itself. http://wildermuth.com/2008/03/31/Silverlight_2_Bugs_and_Issues.aspx
<Style x:Key="MyImageSetter" TargetType="Image">
<Setter Property="Source" Value="MyImage.JPG"></Setter>
</Style>
But how can I do this with style? Something like this: When I set with this way it gives me image error
-
Hi All, I have one image control, Currently I am setting the image path as absolute. Since the image is at the server side where the Silverlight application is hosted.The source set as follows: <Image x:Name="imgMyImage" Source="http://localhost/MyImage.JPG" > I want to set the relative source from the server in the style. I followed following link and I succeed giving the relative path from the Image tag itself. http://wildermuth.com/2008/03/31/Silverlight_2_Bugs_and_Issues.aspx
<Style x:Key="MyImageSetter" TargetType="Image">
<Setter Property="Source" Value="MyImage.JPG"></Setter>
</Style>
But how can I do this with style? Something like this: When I set with this way it gives me image error
Your post is messed up so I can't see what you may have done wrong. URIs for resource files are described here: Resource Files[^]
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
Hi All, I have one image control, Currently I am setting the image path as absolute. Since the image is at the server side where the Silverlight application is hosted.The source set as follows: <Image x:Name="imgMyImage" Source="http://localhost/MyImage.JPG" > I want to set the relative source from the server in the style. I followed following link and I succeed giving the relative path from the Image tag itself. http://wildermuth.com/2008/03/31/Silverlight_2_Bugs_and_Issues.aspx
<Style x:Key="MyImageSetter" TargetType="Image">
<Setter Property="Source" Value="MyImage.JPG"></Setter>
</Style>
But how can I do this with style? Something like this: When I set with this way it gives me image error
1. Build Action of Image = Resource 2. <UserControl x:Class="SilverlightApplication3.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480"> <UserControl.Resources> <Style x:Key="MyImageSetter" TargetType="Image"> <Setter Property="Source" Value="Al Pascual.jpg" /> </Style> </UserControl.Resources> <Grid x:Name="LayoutRoot"> <Image Style="{StaticResource MyImageSetter}" /> </Grid> </UserControl>
Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) Microsoft MVP (Silverlight), WPF/Silverlight Insiders