locked
how to display an image in a Popup control ? RRS feed

  • Question

  • Im really struggling to display an image inside a popup control but I'm able to display other controls ,what am i doing wrong ?

    here is my code

      <Popup x:Name="sideBarPopout"  IsOpen="False" IsLightDismissEnabled="True"  FlowDirection="LeftToRight">
                            <Popup.ChildTransitions>
                                <TransitionCollection>
                                    <PaneThemeTransition Edge="Left" />
                                </TransitionCollection>
                            </Popup.ChildTransitions>
                            <Border  BorderThickness="0"  x:Name="RootPopupBorder" Width="333">
                                <StackPanel Orientation="Vertical" Background="#D1D1D1" Height="500"  x:Name="pop" Width="300" >
                                    <StackPanel Orientation="Horizontal" Height="90">
                                        <Image Source="Assets/board_meetings_icon.png"  Stretch="UniformToFill"/>
                                         <TextBlock Text="Meetings" Foreground="White" FontSize="20"/>
                                    </StackPanel>
                                    <StackPanel Orientation="Horizontal"  HorizontalAlignment="Center">
                                        <TextBlock Text="Board Members" Foreground="White" FontSize="20"/>
                                    </StackPanel>
                                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
                                        <TextBlock Text="record" Foreground="White" FontSize="20"/>
                                    </StackPanel>
                                    <StackPanel Orientation="Horizontal"  HorizontalAlignment="Center">
                                        <TextBlock Text="Help" Foreground="White" FontSize="20"/>
                                    </StackPanel>
                                    <StackPanel HorizontalAlignment="Center">
                                        <TextBlock Text="Settings" Foreground="White" FontSize="20"/>
                                    </StackPanel>
                                </StackPanel>
                            </Border>
                        </Popup>

     

    19karabo91

    Wednesday, January 15, 2014 1:32 PM

Answers

  • I placed a working example of your code here, so you can compare with what you have on your side.

    And here's another hint: check the file extension. It wouldn't be the first time that I looked for a .png, while there's actually a .jpg in the folder.

    • Marked as answer by 19karabo91 Thursday, January 16, 2014 8:40 AM
    Thursday, January 16, 2014 8:15 AM

All replies

  • There seems to be nothing wrong with the XAML itself. Can you double check whether

    1. The relative path to the image is correct, and
    2. the 'Build Action' property of the image is set to 'Content'?
    • Proposed as answer by Vishal Kaushik Wednesday, January 15, 2014 5:39 PM
    Wednesday, January 15, 2014 2:04 PM
  • In addition to Diederik's questions: what specifically isn't working? How is the actual behavior different from the expected behavior?

    The only obvious problem with your Xaml is hardcoded colours, but that will break high contrast mode but not affect your image.

    --Rob

    Wednesday, January 15, 2014 3:50 PM
    Moderator
  • I did that and still the image is not displayed 

    19karabo91

    Thursday, January 16, 2014 6:48 AM
  • the main problem is that the image can't be displayed where i've placed it on the popup control but text block is displayed 

    19karabo91

    Thursday, January 16, 2014 6:51 AM
  • I placed a working example of your code here, so you can compare with what you have on your side.

    And here's another hint: check the file extension. It wouldn't be the first time that I looked for a .png, while there's actually a .jpg in the folder.

    • Marked as answer by 19karabo91 Thursday, January 16, 2014 8:40 AM
    Thursday, January 16, 2014 8:15 AM
  • Thanks a lot Diederik ,i don't know what i was doing wrong ,i just copied your code and paste it everything works fine now Thank you so much . 

    19karabo91

    Thursday, January 16, 2014 8:42 AM