简体   繁体   中英

Using XAML and ironpython in WPF, image shows in designer window but not when I run the program

I'm working on a project for school, I am extremely knew to ironpython. I am trying to work with a couple of images. I want to be able to drag them using the mouse, but I can't even get the image to show up on the form when I run the program. It shows just fine inside the designer, and disappears once I run the program.

here is my code so far...

<Window 
       xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
       xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
       Title="WpfApplication3" Height="1000" Width="1000" Background="Green"> 
       <Grid>

        <Button Width="75" Height="50" Click="Button_Click">Push Me</Button>
        <Image  HorizontalAlignment="Left" Height="100" Margin="289,460,0,0" VerticalAlignment="Top" Width="100">
            <Image.Source>
                <BitmapImage UriSource="/Images/atlantafalcons.jpg" />
            </Image.Source>
        </Image>
    </Grid>
</Window> 

I don't understand what I am doing wrong...

Just remove first backslash:

<Grid>
    <Button Width="75" Height="50" Click="Button_Click">Push Me</Button>
    <Image  HorizontalAlignment="Left" Height="100" Margin="289,460,0,0" VerticalAlignment="Top" Width="100">
        <Image.Source>               
            <BitmapImage UriSource="Images/atlantafalcons.jpg" />
        </Image.Source>
    </Image>
</Grid>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM