wpf 错误内存不足,无法在 visual studio 2012 年继续执行
wpf error insufficient memory to continue execution in visual studio 2012
我是 wpf 的新手,我正在使用它开发一个非常简单的应用程序。
我有一个 window,我在其中放置了一个停靠面板,停靠面板有两个菜单,
"Action->About,Help,Exit"
&
"Area-> Area1, Area2,Area3"
在区域菜单中单击 area1 时,我会在同一 window 中加载用户控件。这个用户控件有一个网格。整个网格分为40行40列,网格的背景是一张横跨整个网格的图片。实际上我的想法是将图像分成 160 个可点击的相等正方形。
在 40 交叉 40 网格的每个单元格中,我放置了一个透明按钮,其名称为增量名称,如 b1、b2、b3...直到 b160。单击任何按钮时,将执行 anybuttonclick 方法(我在后面的代码中定义)
我在解决方案目录的单独文件夹中也有 160 个单独的高分辨率图像,所有这些图像的名称也被放置为 b1.jpg、b2.jpg、b3.jpg.. 最多 b160.jpg !!!
在后面的代码中,我放置了 anybuttonclick 方法,在该方法中我获得了用户单击的按钮的名称,并且借助于此我能够决定在新的 window 中加载哪个图像。例如,如果用户单击 b35,我会在新 window 中加载图像 b35.jpg。新 window 中的这张图像是高分辨率图像(单元格 1 的缩放版本)。
我对 area2 也有同样的看法..
到目前为止,area1 文件夹中的图像大小为 670 mb,图像数量为 160
area2 文件夹中的图像大小为 785 mb,图像数量为 160
一切正常。仅当我尝试对 area3 执行相同操作时才会出现问题。即当我尝试将 area3 的高分辨率图像复制到名为“images3”的文件夹中时
area3 文件夹中的图像数量为 160,图像大小为 783 mb
我有时会收到错误消息,说运行时出现内存不足异常。有时它说内存不足,无法继续执行。
然后我删除了 area3 的图像(每个区域有 160 张图像)我能够正确调试项目。
我试图发布只有两个区域的应用程序。并在我的系统上进行了测试。它工作正常。(intel core i5 2.4 ghz 16 gb ram windows 7 32 位,visual studio 2012)
但是,当我将相同的已发布应用程序转移到我的笔记本电脑(intel core i7 2.4 ghz,4 gb ram windows 7 32 位,visual studio 2012)时,应用程序在安装时崩溃。
我的问题是 wpf 有什么问题?没有任何限制。我们可以使用的图像数量或图像大小?我尝试对 v2012 应用修补程序仍然是同样的问题。开发这样的应用程序的最佳实践是什么,当涉及到在您的解决方案中包含大量图像时 directory.i 不想使用 sql 来存储图像,因为我不想妥协关于图像质量。
DalLake.xaml
中的代码
<UserControl x:Class="HmiLike.Pages.DalLake"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:pages="clr-namespace:HmiLike.Pages"
mc:Ignorable="d"
d:DesignHeight="800" d:DesignWidth="800"
>
<Grid>
<Grid.Background>
<ImageBrush ImageSource="/Images/background.jpg">
</ImageBrush>
</Grid.Background>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50*"/>
<ColumnDefinition Width="44*"/>
<ColumnDefinition Width="42*"/>
<ColumnDefinition Width="44*"/>
<ColumnDefinition Width="45*"/>
<ColumnDefinition Width="45*"/>
<ColumnDefinition Width="44*"/>
<ColumnDefinition Width="44*"/>
<ColumnDefinition Width="43*"/>
<ColumnDefinition Width="47*"/>
<ColumnDefinition Width="44*"/>
<ColumnDefinition Width="42*"/>
<ColumnDefinition Width="45*"/>
<ColumnDefinition Width="13*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="50*"/>
<RowDefinition Height="46*"/>
<RowDefinition Height="44*"/>
<RowDefinition Height="42*"/>
<RowDefinition Height="45*"/>
<RowDefinition Height="45*"/>
<RowDefinition Height="44*"/>
<RowDefinition Height="44*"/>
<RowDefinition Height="43*"/>
<RowDefinition Height="46*"/>
<RowDefinition Height="45*"/>
<RowDefinition Height="41*"/>
<RowDefinition Height="45*"/>
<RowDefinition Height="45*"/>
<RowDefinition Height="45*"/>
<RowDefinition Height="44*"/>
<RowDefinition Height="46*"/>
<RowDefinition Height="11*"/>
</Grid.RowDefinitions>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="5" Grid.Row="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_001" Click="anyButtonClicked" />
<Button Grid.ColumnSpan="1" Content="" Grid.Column="6" Grid.Row="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_002" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="7" Grid.Row="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_003" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="4" Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_004" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="5" Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_005" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="6" Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_006" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="7" Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_007" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="8" Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_008" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="4" Grid.Row="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_009" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="5" Grid.Row="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_010" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="6" Grid.Row="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_011" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="7" Grid.Row="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_012" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="8" Grid.Row="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_013" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="9" Grid.Row="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_014" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="4" Grid.Row="3" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_015" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="5" Grid.Row="3" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_016" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="6" Grid.Row="3" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_017" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="7" Grid.Row="3" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_018" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="8" Grid.Row="3" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_019" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="9" Grid.Row="3" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_020" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="2" Grid.Row="4" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_021" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="3" Grid.Row="4" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_022" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="4" Grid.Row="4" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_023" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="5" Grid.Row="4" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_024" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="6" Grid.Row="4" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_025" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="7" Grid.Row="4" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_026" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="8" Grid.Row="4" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_027" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="9" Grid.Row="4" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_028" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="10" Grid.Row="4" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_029" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="11" Grid.Row="4" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_030" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="1" Grid.Row="5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_031" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="2" Grid.Row="5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_032" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="3" Grid.Row="5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_033" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="4" Grid.Row="5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_034" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="5" Grid.Row="5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_035" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="6" Grid.Row="5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_036" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="7" Grid.Row="5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_037" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="8" Grid.Row="5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_038" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="9" Grid.Row="5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_039" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="10" Grid.Row="5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_040" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="11" Grid.Row="5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_041" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="12" Grid.Row="5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_042" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="1" Grid.Row="6" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_043" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="2" Grid.Row="6" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_044" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="3" Grid.Row="6" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_045" Click="anyButtonClicked"/>
<!--<CheckBox Content="2003:IKONOS" Name="y3" HorizontalAlignment="Stretch" Grid.Row="1" VerticalAlignment="Center" Grid.Column="1" Height="auto" Width="auto" Style="{StaticResource myCheckboxStyle}" Grid.ColumnSpan="4" FontWeight="Bold" FontSize="18" Foreground="White"/>-->
<RadioButton Content="2003:IKONOS" Name="y3" HorizontalAlignment="Stretch" Grid.Row="1" VerticalAlignment="Center" Grid.Column="1" Height="auto" Width="auto" Grid.ColumnSpan="4" FontWeight="Bold" FontSize="18" Foreground="White"/>
<!--<RadioButton Content="2007:QUICKBIRD" Name="y7" HorizontalAlignment="Stretch" Grid.Row="2" VerticalAlignment="Center" Grid.Column="1" Height="auto" Width="auto" Grid.ColumnSpan="4" FontWeight="Bold" FontSize="18" Foreground="White" />-->
<RadioButton Content="2014:GEOEYE" Name="y14" HorizontalAlignment="Stretch" Grid.Row="3" VerticalAlignment="Center" Grid.Column="1" Height="auto" Width="auto" Grid.ColumnSpan="4" FontWeight="Bold" FontSize="18" Foreground="White" />
<pages:SwitcherMenu Grid.Row="0" Grid.ColumnSpan="30" Height="20" VerticalAlignment="Top" Width="auto"/>
</Grid>
</UserControl>
DalLake.cs
中的代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace HmiLike.Pages
{
/// <summary>
/// Interaction logic for DalLake.xaml
/// </summary>
public partial class DalLake : UserControl
{
public DalLake()
{
InitializeComponent();
}
private void anyButtonClicked(object sender, RoutedEventArgs e)
{
//CHECKING WHICH CheckBox isChecked
if (y3.IsChecked == true)
{
var source = e.OriginalSource as FrameworkElement;
if (source == null)
return;
Year2003 Year2003_Window = new Year2003();
string imagename = "Images\"+"Dal\"+"y3\" + source.Name.ToString() + ".jpg";
//Year2003_Window.win2label.Content = imagename;
Year2003_Window.gridimage.Source = new BitmapImage(new Uri(imagename, UriKind.Relative));
Year2003_Window.Show();
}
//else if (y7.IsChecked == true)
//{
// var source = e.OriginalSource as FrameworkElement;
// if (source == null)
// return;
// Year2007 Year2007_Window = new Year2007();
// string imagename = "Images\" + "Dal\" + "y7\" + source.Name.ToString() + ".jpg";
// //Year2007_Window.win2label.Content = imagename;
// Year2007_Window.gridimage.Source = new BitmapImage(new Uri(imagename, UriKind.Relative));
// Year2007_Window.Show();
// Year2007_Window.Show();
//}
else if (y14.IsChecked == true)
{
var source = e.OriginalSource as FrameworkElement;
if (source == null)
return;
Year2014 Year2014_Window = new Year2014();
string imagename = "Images\" + "Dal\" + "y14\" + source.Name.ToString() + ".jpg";
Year2014_Window.gridimage.Source = new BitmapImage(new Uri(imagename, UriKind.Relative));
Year2014_Window.Show();
Year2014_Window.Show();
}
}
}
}
这是我在清单文件中添加的代码
<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
</application>
</compatibility>
</asmv1:assembly>
您的 Visual Studio 在尝试创建清单文件时崩溃,因为您的清单文件变大了。
根据你的this article you should change the build mode张图片。
我会尝试构建模式 "resource",但我无法测试它。
"Action->About,Help,Exit" & "Area-> Area1, Area2,Area3"
在区域菜单中单击 area1 时,我会在同一 window 中加载用户控件。这个用户控件有一个网格。整个网格分为40行40列,网格的背景是一张横跨整个网格的图片。实际上我的想法是将图像分成 160 个可点击的相等正方形。 在 40 交叉 40 网格的每个单元格中,我放置了一个透明按钮,其名称为增量名称,如 b1、b2、b3...直到 b160。单击任何按钮时,将执行 anybuttonclick 方法(我在后面的代码中定义) 我在解决方案目录的单独文件夹中也有 160 个单独的高分辨率图像,所有这些图像的名称也被放置为 b1.jpg、b2.jpg、b3.jpg.. 最多 b160.jpg !!! 在后面的代码中,我放置了 anybuttonclick 方法,在该方法中我获得了用户单击的按钮的名称,并且借助于此我能够决定在新的 window 中加载哪个图像。例如,如果用户单击 b35,我会在新 window 中加载图像 b35.jpg。新 window 中的这张图像是高分辨率图像(单元格 1 的缩放版本)。
我对 area2 也有同样的看法.. 到目前为止,area1 文件夹中的图像大小为 670 mb,图像数量为 160 area2 文件夹中的图像大小为 785 mb,图像数量为 160
一切正常。仅当我尝试对 area3 执行相同操作时才会出现问题。即当我尝试将 area3 的高分辨率图像复制到名为“images3”的文件夹中时 area3 文件夹中的图像数量为 160,图像大小为 783 mb 我有时会收到错误消息,说运行时出现内存不足异常。有时它说内存不足,无法继续执行。 然后我删除了 area3 的图像(每个区域有 160 张图像)我能够正确调试项目。 我试图发布只有两个区域的应用程序。并在我的系统上进行了测试。它工作正常。(intel core i5 2.4 ghz 16 gb ram windows 7 32 位,visual studio 2012) 但是,当我将相同的已发布应用程序转移到我的笔记本电脑(intel core i7 2.4 ghz,4 gb ram windows 7 32 位,visual studio 2012)时,应用程序在安装时崩溃。
我的问题是 wpf 有什么问题?没有任何限制。我们可以使用的图像数量或图像大小?我尝试对 v2012 应用修补程序仍然是同样的问题。开发这样的应用程序的最佳实践是什么,当涉及到在您的解决方案中包含大量图像时 directory.i 不想使用 sql 来存储图像,因为我不想妥协关于图像质量。
DalLake.xaml
中的代码<UserControl x:Class="HmiLike.Pages.DalLake"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:pages="clr-namespace:HmiLike.Pages"
mc:Ignorable="d"
d:DesignHeight="800" d:DesignWidth="800"
>
<Grid>
<Grid.Background>
<ImageBrush ImageSource="/Images/background.jpg">
</ImageBrush>
</Grid.Background>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50*"/>
<ColumnDefinition Width="44*"/>
<ColumnDefinition Width="42*"/>
<ColumnDefinition Width="44*"/>
<ColumnDefinition Width="45*"/>
<ColumnDefinition Width="45*"/>
<ColumnDefinition Width="44*"/>
<ColumnDefinition Width="44*"/>
<ColumnDefinition Width="43*"/>
<ColumnDefinition Width="47*"/>
<ColumnDefinition Width="44*"/>
<ColumnDefinition Width="42*"/>
<ColumnDefinition Width="45*"/>
<ColumnDefinition Width="13*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="50*"/>
<RowDefinition Height="46*"/>
<RowDefinition Height="44*"/>
<RowDefinition Height="42*"/>
<RowDefinition Height="45*"/>
<RowDefinition Height="45*"/>
<RowDefinition Height="44*"/>
<RowDefinition Height="44*"/>
<RowDefinition Height="43*"/>
<RowDefinition Height="46*"/>
<RowDefinition Height="45*"/>
<RowDefinition Height="41*"/>
<RowDefinition Height="45*"/>
<RowDefinition Height="45*"/>
<RowDefinition Height="45*"/>
<RowDefinition Height="44*"/>
<RowDefinition Height="46*"/>
<RowDefinition Height="11*"/>
</Grid.RowDefinitions>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="5" Grid.Row="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_001" Click="anyButtonClicked" />
<Button Grid.ColumnSpan="1" Content="" Grid.Column="6" Grid.Row="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_002" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="7" Grid.Row="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_003" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="4" Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_004" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="5" Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_005" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="6" Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_006" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="7" Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_007" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="8" Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_008" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="4" Grid.Row="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_009" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="5" Grid.Row="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_010" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="6" Grid.Row="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_011" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="7" Grid.Row="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_012" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="8" Grid.Row="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_013" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="9" Grid.Row="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_014" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="4" Grid.Row="3" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_015" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="5" Grid.Row="3" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_016" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="6" Grid.Row="3" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_017" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="7" Grid.Row="3" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_018" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="8" Grid.Row="3" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_019" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="9" Grid.Row="3" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_020" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="2" Grid.Row="4" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_021" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="3" Grid.Row="4" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_022" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="4" Grid.Row="4" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_023" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="5" Grid.Row="4" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_024" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="6" Grid.Row="4" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_025" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="7" Grid.Row="4" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_026" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="8" Grid.Row="4" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_027" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="9" Grid.Row="4" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_028" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="10" Grid.Row="4" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_029" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="11" Grid.Row="4" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_030" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="1" Grid.Row="5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_031" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="2" Grid.Row="5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_032" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="3" Grid.Row="5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_033" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="4" Grid.Row="5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_034" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="5" Grid.Row="5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_035" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="6" Grid.Row="5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_036" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="7" Grid.Row="5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_037" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="8" Grid.Row="5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_038" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="9" Grid.Row="5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_039" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="10" Grid.Row="5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_040" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="11" Grid.Row="5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_041" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="12" Grid.Row="5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_042" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="1" Grid.Row="6" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_043" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="2" Grid.Row="6" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_044" Click="anyButtonClicked"/>
<Button Grid.ColumnSpan="1" Content="" Grid.Column="3" Grid.Row="6" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto" Opacity="0" Name="one_045" Click="anyButtonClicked"/>
<!--<CheckBox Content="2003:IKONOS" Name="y3" HorizontalAlignment="Stretch" Grid.Row="1" VerticalAlignment="Center" Grid.Column="1" Height="auto" Width="auto" Style="{StaticResource myCheckboxStyle}" Grid.ColumnSpan="4" FontWeight="Bold" FontSize="18" Foreground="White"/>-->
<RadioButton Content="2003:IKONOS" Name="y3" HorizontalAlignment="Stretch" Grid.Row="1" VerticalAlignment="Center" Grid.Column="1" Height="auto" Width="auto" Grid.ColumnSpan="4" FontWeight="Bold" FontSize="18" Foreground="White"/>
<!--<RadioButton Content="2007:QUICKBIRD" Name="y7" HorizontalAlignment="Stretch" Grid.Row="2" VerticalAlignment="Center" Grid.Column="1" Height="auto" Width="auto" Grid.ColumnSpan="4" FontWeight="Bold" FontSize="18" Foreground="White" />-->
<RadioButton Content="2014:GEOEYE" Name="y14" HorizontalAlignment="Stretch" Grid.Row="3" VerticalAlignment="Center" Grid.Column="1" Height="auto" Width="auto" Grid.ColumnSpan="4" FontWeight="Bold" FontSize="18" Foreground="White" />
<pages:SwitcherMenu Grid.Row="0" Grid.ColumnSpan="30" Height="20" VerticalAlignment="Top" Width="auto"/>
</Grid>
</UserControl>
DalLake.cs
中的代码using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace HmiLike.Pages
{
/// <summary>
/// Interaction logic for DalLake.xaml
/// </summary>
public partial class DalLake : UserControl
{
public DalLake()
{
InitializeComponent();
}
private void anyButtonClicked(object sender, RoutedEventArgs e)
{
//CHECKING WHICH CheckBox isChecked
if (y3.IsChecked == true)
{
var source = e.OriginalSource as FrameworkElement;
if (source == null)
return;
Year2003 Year2003_Window = new Year2003();
string imagename = "Images\"+"Dal\"+"y3\" + source.Name.ToString() + ".jpg";
//Year2003_Window.win2label.Content = imagename;
Year2003_Window.gridimage.Source = new BitmapImage(new Uri(imagename, UriKind.Relative));
Year2003_Window.Show();
}
//else if (y7.IsChecked == true)
//{
// var source = e.OriginalSource as FrameworkElement;
// if (source == null)
// return;
// Year2007 Year2007_Window = new Year2007();
// string imagename = "Images\" + "Dal\" + "y7\" + source.Name.ToString() + ".jpg";
// //Year2007_Window.win2label.Content = imagename;
// Year2007_Window.gridimage.Source = new BitmapImage(new Uri(imagename, UriKind.Relative));
// Year2007_Window.Show();
// Year2007_Window.Show();
//}
else if (y14.IsChecked == true)
{
var source = e.OriginalSource as FrameworkElement;
if (source == null)
return;
Year2014 Year2014_Window = new Year2014();
string imagename = "Images\" + "Dal\" + "y14\" + source.Name.ToString() + ".jpg";
Year2014_Window.gridimage.Source = new BitmapImage(new Uri(imagename, UriKind.Relative));
Year2014_Window.Show();
Year2014_Window.Show();
}
}
}
}
这是我在清单文件中添加的代码
<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
</application>
</compatibility>
</asmv1:assembly>
您的 Visual Studio 在尝试创建清单文件时崩溃,因为您的清单文件变大了。
根据你的this article you should change the build mode张图片。
我会尝试构建模式 "resource",但我无法测试它。