WPF 多线程处理(6)

 

 

 

 

 

以下是子窗体的UI:

复制代码
<Window x:Class="Automatically.View"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="View" 
        SizeToContent="WidthAndHeight"
        WindowStartupLocation="CenterScreen"
        Icon="/Automatically;component/Images/schedule.ico"
        >
    <Grid>
        <DockPanel>
            <Image Name="Icon" Width="35" Height="35" DockPanel.Dock="Left"/>
            <TextBlock Name="tbk_Files"></TextBlock>
        </DockPanel>
    </Grid>
</Window>
View Code
复制代码

 

 

子窗体的代码:

复制代码
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.Shapes;

namespace Automatically
{
    /// <summary>
    /// Interaction logic for View.xaml
    /// </summary>
    public partial class View : Window
    {
        private object lbi;

        public View(object lbi)
        {
            InitializeComponent();
            // TODO: Complete member initialization
            this.lbi = lbi;

            this.Dispatcher.Invoke(new Action(delegate
            {

                DockPanel dp = lbi as DockPanel;

                foreach (UIElement ele in dp.Children)
                {
                    if (ele is Image)
                    {
                        Image img = ele as Image;
                        Icon.Source = img.Source;
                    }
                    if (ele is TextBlock)
                    {
                        TextBlock tbk = ele as TextBlock;
                        foreach (var t in tbk.Inlines)
                        {
                            if (t is Run)
                            {
                                Run r = t as Run;
                                tbk_Files.Inlines.Add(new Run(r.Text));
                            }
                            if (t is LineBreak)
                            {
                                LineBreak l = t as LineBreak;
                                tbk_Files.Inlines.Add(new LineBreak());
                            }
                        }
                    }
                }
            }));
        }
    }
}
View Code
复制代码

 

 

到此就完结了,希望给各位初学WPF的一些提示.

 

需要源码的小朋友可以留言啦!!!

 

posted @   风清扬 No.1  阅读(1242)  评论(20编辑  收藏  举报
编辑推荐:
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
阅读排行:
· 单线程的Redis速度为什么快?
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 展开说说关于C#中ORM框架的用法!
· SQL Server 2025 AI相关能力初探
· Pantheons:用 TypeScript 打造主流大模型对话的一站式集成库
点击右上角即可分享
微信分享提示