那啥,是从这里整理出来的,感谢Rising_Sun,整理的过于简单,看不明白的戳这里

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 Delegate委托
{
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
delegate string SayMessage(string msg);
static string SayHello(string Name)
{
return string.Format("Hello {0}", Name);
}
private void button1_Click(object sender, RoutedEventArgs e)
{
SayMessage say = new SayMessage(SayHello);
textBlock1.Text = say("委托");
} private void button2_Click(object sender, RoutedEventArgs e)
{
SayMessage say = delegate(string Name)
{
return string.Format("Hello {0}", Name);
};
textBlock2.Text = say("匿名方法");
} private void button3_Click(object sender, RoutedEventArgs e)
{
SayMessage say = (Name) =>
{
return string.Format("Hello {0}", Name);
};
textBlock3.Text = say("Lambda");
}
private void button4_Click(object sender, RoutedEventArgs e)
{
Func<string, string> say1 = delegate(string Name)
{
return string.Format("Hello {0}", Name);
};
//和Lambda 结合
Func<string, string> say2 = (Name) =>
{
return string.Format("Hello {0}", Name);
};
textBlock4.Text = say1("Func 委托") + say2("Func+Lambda 委托");
}
private void button5_Click(object sender, RoutedEventArgs e)
{
Action<string> say1 = delegate(string Name)
{
textBlock5.Text = (string.Format("Hello {0}", Name));
};
//和Lambda 结合
Action<string> say2 = (Name) =>
{
textBlock5.Text += (string.Format("Hello {0}", Name));
};
say1("Action 委托");
say2("Action+Lambda 委托");
}
}
}

下面那啥,不堪入目!没人看到没人看到没人看到。。。。。。

<Window x:Class="Delegate委托.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="" Width="">
<Grid>
<Button Content="Button" Height="" HorizontalAlignment="Left" Margin="34,12,0,0" Name="button1" VerticalAlignment="Top" Width="" Click="button1_Click" />
<TextBlock Height="" HorizontalAlignment="Left" Margin="166,12,0,0" Name="textBlock1" Text="TextBlock" VerticalAlignment="Top" Width=""/>
<Button Content="Button" Height="" HorizontalAlignment="Left" Margin="34,58,0,0" Name="button2" VerticalAlignment="Top" Width="" Click="button2_Click" />
<TextBlock Height="" HorizontalAlignment="Left" Margin="165,58,0,0" Name="textBlock2" Text="TextBlock" VerticalAlignment="Top" Width="" />
<Button Content="Button" Height="" HorizontalAlignment="Left" Margin="34,108,0,0" Name="button3" VerticalAlignment="Top" Width="" Click="button3_Click" />
<TextBlock Height="" HorizontalAlignment="Left" Margin="165,108,0,0" Name="textBlock3" Text="TextBlock" VerticalAlignment="Top" Width="" TextWrapping="Wrap"/>
<Button Content="Button" Height="" HorizontalAlignment="Left" Margin="34,158,0,0" Name="button4" VerticalAlignment="Top" Width="" Click="button4_Click" />
<TextBlock Height="" HorizontalAlignment="Left" Margin="165,158,0,0" Name="textBlock4" Text="TextBlock" VerticalAlignment="Top" Width="" TextWrapping="Wrap" />
<Button Content="Button" Height="" HorizontalAlignment="Left" Margin="34,208,0,0" Name="button5" VerticalAlignment="Top" Width="" Click="button5_Click" />
<TextBlock Height="" HorizontalAlignment="Left" Margin="165,208,0,0" Name="textBlock5" Text="TextBlock" VerticalAlignment="Top" Width="" TextWrapping="Wrap"/> </Grid>
</Window>

咳咳,反正是自己看的

WPF Delegate委托整理的更多相关文章

  1. 快速理解C#高级概念(一) Delegate委托

    做.NET开发很久,最近重新温习<C#高级编程>一书.发现很多曾经似懂非懂的问题,其实也是能够慢慢钻研慢慢理解的. 所以,打算开写<C#高级编程系列>博文.其中会借鉴<C ...

  2. 关于js模拟c#的Delegate(委托)实现

    这是我的第一篇博文,想来讲一讲js的函数.我的标题是js模拟c#的Delegate. 一.什么是Delegate(委托) 在jquery中有delegate函数,作用是将某个dom元素的标签的事件委托 ...

  3. (转)WPF学习资源整理

    由于笔者正在学习WPF,所以整理出网络中部分WPF的学习资源,希望对同样在学习WPF的朋友们有所帮助. 首推刘铁猛的<深入浅出WPF>系列博文 1.深入浅出WPF(1)——什么是WPFht ...

  4. WPF学习资源整理

    WPF(WindowsPresentation Foundation)是微软推出的基于Windows Vista的用户界面框架,属于.NET Framework 3.0的一部分.它提供了统一的编程模型 ...

  5. 使用 EPPlus 封装的 excel 表格导入功能 (二) delegate 委托 --永远滴神

    使用 EPPlus 封装的 excel 表格导入功能 (二) delegate 委托 --永远滴神 前言 接上一篇 使用 EPPlus 封装的 excel 表格导入功能 (一) 前一篇的是大概能用但是 ...

  6. 【UE4 C++ 基础知识】<8> Delegate 委托

    概念 定义 UE4中的delegate(委托)常用于解耦不同对象之间的关联:委托的触发者不与监听者有直接关联,两者通过委托对象间接地建立联系. 监听者通过将响应函数绑定到委托上,使得委托触发时立即收到 ...

  7. C# WPF 使用委托修改UI控件

    近段时间在自学WPF,是一个完全不懂WPF的菜鸟,对于在线程中修改UI控件使用委托做一个记录,给自已以后查询也给需要的参考: 界面只放一个RichTextBox,在窗体启动时开起两个线程,调用两个函数 ...

  8. C# WPF 通过委托实现多窗口间的传值

    在使用WPF开发的时候就不免会遇到需要两个窗口间进行传值操作,当然多窗口间传值的方法有很多种,本文介绍的是使用委托实现多窗口间的传值. 在上代码之前呢,先简单介绍一下什么是C#中的委托(如果只想了解如 ...

  9. C#中的委托 Delegate(委托 也叫代表,代表一类方法)

    1. 委托类似与 C或C++中的函数指针,但委托是 面向对象的,并且是类型安全的 详情可查看官方文档:https://msdn.microsoft.com/en-us/library/ms173172 ...

随机推荐

  1. DELPHI SOKET 编程(使用TServerSocket和TClientSocket)

    本文采用delphi7+TServerSocket+TClientSocket; 笔者在工作中遇到对局域网中各工作站与服务器之间进行Socket通信的问题.现在将本人总结出来的TServerSocke ...

  2. 《转》Linux下的多线程编程

    原地址:http://linux.chinaunix.net/doc/program/2001-08-11/642.shtml 1 引言 线程(thread)技术早在60年代就被提出,但真正应用多线程 ...

  3. [Cocos2d-x学习笔记]Android NDK: Host 'awk' tool is outdated. Please define NDK_HOST_AWK to point to Gawk or Nawk解决方案

    Android NDK: Host 'awk' tool is outdated. Please define NDK_HOST_AWK to point to Gawk or Nawkawk过期网上 ...

  4. 【图像处理】Bilinear Image Scaling

    Bilinear image scaling is about the same as nearest neighbor image scaling except with interpolation ...

  5. mysql 数据库备份ubuntu

    安装 1 sudo apt-get update 2. sudo apt-get install mysql-server 3 sudo  apt-get install mysql-client 4 ...

  6. NSDictionary、NSMutableDictionary基本使用

    郝萌主倾心贡献,尊重作者的劳动成果.请勿转载. 假设文章对您有所帮助,欢迎给作者捐赠,支持郝萌主,捐赠数额任意,重在心意^_^ 我要捐赠: 点击捐赠 Cocos2d-X源代码下载:点我传送 游戏官方下 ...

  7. xcode6 iOS sdk8.1隐藏系统状态栏

    在代码项目(uzplayer)从iOS6升级到iOS8之后,头发如今视频播放器有.系统状态栏后面的背景: 这样就会导致有的时候按下Donebutton,或者拖滑块没有效果 所以,我们须要想个办法.把这 ...

  8. [置顶] ANDROID 返回,菜单和HOME键的监听

    ------网上找了很多资料,项目中使用,最后将经验总结如下: 1,返回和菜单键是可以直接重写onKeyDown(int keyCode, KeyEvent event) 方法监听: @Overrid ...

  9. Application to find the maximum temperature in the weather dataset

    import org.apache.hadoop.fs.Path; import org.apache.hadoop.io.IntWritable; import org.apache.hadoop. ...

  10. 组件-------(一)redis系列--安装部署redis+实现redis分布式缓存 java+Spring+redis

    目的:解决单机session不能共享问题,插入查询数据库时间效率问题,实现分布式缓存. 准备材料:Redis 下载链接 http://pan.baidu.com/s/1dEGTxvV 相关jar包如果 ...