如题,在出现的界面中按F5键会调用xaml的后台文件(.cs)中的如下函数:private void Skip_Execute(object sender, ExecutedRoutedEventArgs e)
{
show_all_word_picture();
success_wnd_is_create = true;
}
private void Skip_Enable(object sender, CanExecuteRoutedEventArgs e)
{
e.CanExecute = true;
}
private void show_all_word_picture()
{
/* 加亮所有文字 */
for (int i = BeginNum; i <= EndNum; i++)
{
try
{
string control_name = "pictureBox" + i.ToString();
var picturebox = this.FindName(control_name) as Image;
if (picturebox != null)
{
string pic_path = "image/" + i.ToString() + ".png";
picturebox.Source = LoadBitmapFromResource(pic_path);
}
}
catch (System.Exception ex)
{
}
System.Threading.Thread.Sleep(100); }
}
public static BitmapImage LoadBitmapFromResource(string pathInApplication, Assembly assembly = null)
{
if (assembly == null)
{
assembly = Assembly.GetCallingAssembly();
} if (pathInApplication[0] == '/')
{
pathInApplication = pathInApplication.Substring(1);
}
return new BitmapImage(new Uri(@"pack://application:,,,/" + assembly.GetName().Name + ";component/" + pathInApplication, UriKind.Absolute));
}
根据断点跟踪,必须等Skip_Execute(object sender, ExecutedRoutedEventArgs e)函数执行完成后,show_all_word_picture()函数中修改的图片才会在屏幕上显示。请问各位大神这是什么原因。xaml图片c#
{
show_all_word_picture();
success_wnd_is_create = true;
}
private void Skip_Enable(object sender, CanExecuteRoutedEventArgs e)
{
e.CanExecute = true;
}
private void show_all_word_picture()
{
/* 加亮所有文字 */
for (int i = BeginNum; i <= EndNum; i++)
{
try
{
string control_name = "pictureBox" + i.ToString();
var picturebox = this.FindName(control_name) as Image;
if (picturebox != null)
{
string pic_path = "image/" + i.ToString() + ".png";
picturebox.Source = LoadBitmapFromResource(pic_path);
}
}
catch (System.Exception ex)
{
}
System.Threading.Thread.Sleep(100); }
}
public static BitmapImage LoadBitmapFromResource(string pathInApplication, Assembly assembly = null)
{
if (assembly == null)
{
assembly = Assembly.GetCallingAssembly();
} if (pathInApplication[0] == '/')
{
pathInApplication = pathInApplication.Substring(1);
}
return new BitmapImage(new Uri(@"pack://application:,,,/" + assembly.GetName().Name + ";component/" + pathInApplication, UriKind.Absolute));
}
根据断点跟踪,必须等Skip_Execute(object sender, ExecutedRoutedEventArgs e)函数执行完成后,show_all_word_picture()函数中修改的图片才会在屏幕上显示。请问各位大神这是什么原因。xaml图片c#
解决方案 »
- 委托 事件 监听 .net
- c#跳转致首页问题
- 菜鸟问题:使用API函数SetParent之后无法显示ToolTip气泡-50分
- 定时删除历史记录
- c#progressBar到头后,怎样重新开始
- 用C#开发客户端是否是个聪明的决择?
- 关于 DataSet 中执行 SQL 语句的问题, 对于CS_N 的垃圾搜索我很是不想再用,还不如我写的
- 怎样获取整个页面所有TextBox空件,并统一给它赋值(c#.net)。
- 谁知道微软的Money2005的本地版本(下载后使用的)是用什么工具开发的?
- c#怎么做一个定时运行程序!!!
- winform中的SplitContainer控件 如何使它的边框变成实线?
- File.Copy覆盖一个文件后,想再一次覆盖,就提示资源已经打开
picturebox.Dispatcher.Invoke(DispatcherPriority.Render, (Action)delegate(){}); //<--