Metro UI的:我切换XAML,但图像不加载 [英] Metro UI: I'm switching xaml but images not loading
本文介绍了Metro UI的:我切换XAML,但图像不加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个多XAML地铁应用程序。我想通过点击按钮XAML之间进行切换。
I have a multi-xaml metro app. I want to switch between xaml by button click.
private void Button_Click_1(object sender, RoutedEventArgs e)
{
Window.Current.Content = new BlankPage1();
this.InitializeComponent();
}
private void Button_Click_2(object sender, RoutedEventArgs e)
{
Window.Current.Content = new Sudoku.sudoku();
Window.Current.Activate();
}
private void Button_Click_3(object sender, RoutedEventArgs e)
{
TextTwist.text_twist ob= new TextTwist.text_twist();
ob.InitializeComponent();
Window.Current.Content = ob;
}
这是主要的有XAML按钮逻辑代码。
现在,当我点击按钮1(/按钮2 /按钮3),相应的XAML来在屏幕上,但相关的图像不会加载。
他们是在设计,否则完全可见。
This is the logic code for the main xaml having buttons. Now when I click button1 (/button2/button3), the corresponding xaml comes on screen, but the associated images are not loaded. They are perfectly visible in the designer otherwise.
请帮助我。
下面是格X;在XAML代码片段
Here is 1 of the xaml snippet
<Grid x:Name="gridMain">
<Grid.Background>
<ImageBrush ImageSource="Assets/textTwist/blue_back.png"/>
</Grid.Background>
<ListView x:Name="lv" HorizontalAlignment="Left" Height="565" Margin="49,99,0,0" VerticalAlignment="Top" Width="315" SelectionChanged="ListView_SelectionChanged_1" Opacity="0.95" FontSize="128">
<ListView.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="Black" Offset="1"/>
<GradientStop Color="#FF9CF147" Offset="0.261"/>
</LinearGradientBrush>
</ListView.Background>
</ListView>
<TextBox x:Name="txtblk" HorizontalAlignment="Left" Margin="436,207,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Height="126" Width="731" FontSize="72" AcceptsReturn="True" FontWeight="Bold" BorderThickness="0" Foreground="#FFF01D1D" CharacterSpacing="120">
<TextBox.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="Black"/>
<GradientStop Color="White" Offset="0.874"/>
</LinearGradientBrush>
</TextBox.Background>
</TextBox>
<Button x:Name="btnSubmit" Content="Submit Word" HorizontalAlignment="Left" Margin="874,479,0,0" VerticalAlignment="Top" Width="293" Click="btnSubmit_Click" Height="96" FontSize="36" FontWeight="Normal" FontFamily="Segoe Print">
<Button.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="Black"/>
<GradientStop Color="#FF7DE09C" Offset="0.926"/>
</LinearGradientBrush>
</Button.Background>
</Button>
<Image x:Name="imgWrong" HorizontalAlignment="Left" Height="277" Margin="436,433,0,0" VerticalAlignment="Top" Width="280" Source="Assets/textTwist/wronganswer.png" Stretch="UniformToFill" Visibility="Collapsed"/>
<Image x:Name="imgRight" HorizontalAlignment="Left" Height="277" Margin="436,433,0,0" VerticalAlignment="Top" Width="280" Source="Assets/textTwist/rightanswer.png" Visibility="Collapsed"/>
<Image HorizontalAlignment="Left" Height="146" Margin="480,28,0,0" VerticalAlignment="Top" Width="624" Source="Assets/textTwist/text-twist-turbo-art.jpg" Stretch="UniformToFill"/>
</Grid>
相关图片作为网格背景图像,按钮,图像等。
The associated images being the grid background images, button images etc.
推荐答案
设置图像源的格式MS-应用程序数据或MS-APPX
set your image source with the format ms-appdata or ms-appx
<Image Source="ms-appdata:///local/myFileNotInTheAppPackage.png"/>
<Image Source="ms-appx:///Assets/myFilePartOfMyAppPackage.png"/>
这篇关于Metro UI的:我切换XAML,但图像不加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文