Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. how to set relative image path of image source from style

how to set relative image path of image source from style

Scheduled Pinned Locked Moved WPF
questioncomsysadminhelptutorial
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    salon
    wrote on last edited by
    #1

    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

    M M 2 Replies Last reply
    0
    • S salon

      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

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      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:

      1 Reply Last reply
      0
      • S salon

        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

        M Offline
        M Offline
        Michael Sync
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups