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. Image on Button

Image on Button

Scheduled Pinned Locked Moved WPF
helpcsharpcssvisual-studiowpf
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.
  • U Offline
    U Offline
    User 2322509
    wrote on last edited by
    #1

    Hello All, I have windows application (VS 2008) and i added wpf user control to which i added a button and trying to set image from images folder of my project something like below: <code> <Button Height="23" Margin="117,74,108,0" Name="button1" VerticalAlignment="Top"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions> <Image Grid.Column="0" Source="\images\add.png" /> <TextBlock Grid.Column="1" Text="testing"/> </Grid> </Button> But the compiler always throws error saying "The file images\add.png is not part of the project or its 'Build Action' property is not set to 'Resource'". I changed the build action to "Resource" still doesn't work. The same works in WPF application. Any help greatly appreciated Thanks.

    A M 2 Replies Last reply
    0
    • U User 2322509

      Hello All, I have windows application (VS 2008) and i added wpf user control to which i added a button and trying to set image from images folder of my project something like below: <code> <Button Height="23" Margin="117,74,108,0" Name="button1" VerticalAlignment="Top"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions> <Image Grid.Column="0" Source="\images\add.png" /> <TextBlock Grid.Column="1" Text="testing"/> </Grid> </Button> But the compiler always throws error saying "The file images\add.png is not part of the project or its 'Build Action' property is not set to 'Resource'". I changed the build action to "Resource" still doesn't work. The same works in WPF application. Any help greatly appreciated Thanks.

      A Offline
      A Offline
      ABitSmart
      wrote on last edited by
      #2

      Try Source="images/add.png"

      1 Reply Last reply
      0
      • U User 2322509

        Hello All, I have windows application (VS 2008) and i added wpf user control to which i added a button and trying to set image from images folder of my project something like below: <code> <Button Height="23" Margin="117,74,108,0" Name="button1" VerticalAlignment="Top"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions> <Image Grid.Column="0" Source="\images\add.png" /> <TextBlock Grid.Column="1" Text="testing"/> </Grid> </Button> But the compiler always throws error saying "The file images\add.png is not part of the project or its 'Build Action' property is not set to 'Resource'". I changed the build action to "Resource" still doesn't work. The same works in WPF application. Any help greatly appreciated Thanks.

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

        Yeah : NO BACKSLASHES IN WPF/Silverlight URIs!

        Mark Salsbery Microsoft MVP - Visual C++ :java:

        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