当前位置:网站首页>.NET-7.WPF学习经验总结
.NET-7.WPF学习经验总结
2022-08-10 06:38:00 【joyyi9】
系列文章目录
前言
下面的几个就足够熟悉了。
好好学习,落到实处。
参考链接:
- 官方文档
- WPF从零到1教程详解
- 系列文章(我是有收获的、关于数据绑定理解)
- https://www.cnblogs.com/cdaniu/category/2167439.html
- 触发器
参考代码
//导航
<TextBlock HorizontalAlignment="Left"
Margin="10,10,10,10">
<Hyperlink NavigateUri="Page2.xaml">Go To Page 2</Hyperlink>
</TextBlock>
// 导航
ExpenseReportPage expenseReportPage = new ExpenseReportPage(this.peopleListBox.SelectedItem);
this.NavigationService.Navigate(expenseReportPage);
//获得控件元素
var srcButton = e.Source as Button;
var fe = (FrameworkElement) sender;
var fe2 = (FrameworkElement) args.Source;
//数据简单的绑定
xmlns:local="clr-namespace:WpfApp2"
<local:User x:Key="myData" Name="zhouyi"/>
<TextBox>
<TextBox.Text>
<Binding Source="{StaticResource myData}" Path="Name"
UpdateSourceTrigger="PropertyChanged"/>
</TextBox.Text>
</TextBox>
<TextBlock Text="{Binding Source={StaticResource myData}, Path=Name}"/>
public class User:INotifyPropertyChanged
{
private string _name;
public string? Name
{
get {
return _name; }
set
{
_name = value;
OnPropertyChanged("Name");
}
}
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged(string name)
{
var handler = PropertyChanged;
handler?.Invoke(this, new PropertyChangedEventArgs(name));
}
}
//------------
<Border Margin="10" BorderBrush="Silver" BorderThickness="3" Padding="8">
<DockPanel>
<TextBlock>Choose a Color:</TextBlock>
<ComboBox Name="myComboBo" SelectedIndex="0">
<ComboBoxItem>Green</ComboBoxItem>
<ComboBoxItem>Blue</ComboBoxItem>
<ComboBoxItem>Red</ComboBoxItem>
</ComboBox>
<Canvas>
<Canvas.Background>
<Binding ElementName="myComboBo" Path="SelectedItem.Content"/>
</Canvas.Background>
</Canvas>
</DockPanel>
</Border>
边栏推荐
- Lunix(阿里云服务器)安装Anaconda并开启jupyter服务本地访问
- 1413. Stepwise Summation to Get Minimum Positive Numbers
- Qt程序字体初始化引起的白屏问题
- 如何正确理解线程机制中常见的I/O模型,各自主要用来解决什么问题?
- netlink IPC
- 【电商业务】外行为何难区别 商品属性与商品规格
- Everyone, the default configuration of oracle cdc occasionally takes 30 seconds to capture data. How to optimize this?
- 浅谈C语言实现冒泡排序
- 浅谈C语言整型数据的存储
- Why do games need hot updates
猜你喜欢
随机推荐
CuteOneP 一款php的OneDrive多网盘挂载程序 带会员 同步等功能
2022 Henan Mengxin League No. 5: University of Information Engineering B - Transportation Renovation
ctfshow SSTI 知识点总结
Chapter 12 Other Database Tuning Strategies [2. Index and Tuning] [MySQL Advanced]
排序二叉树代码
一种奇怪的函数声明写法
netlink IPC
I would like to ask you guys, when FLink SQL reads the source, specify the time field of the watermark. If the specified field is in the grid
Please pay attention to me, thank you.
MySQL's InnoDB engine (6)
交换机的功能和ipv4
杭州公积金修改手机号信息
如何治理资源浪费?百度云原生成本优化最佳实践
761. 特殊的二进制序列
XV6系统调用实现
如何正确理解线程机制中常见的I/O模型,各自主要用来解决什么问题?
2022河南萌新联赛第(五)场:信息工程大学 F - 分割草坪
全网可达并设备加密
oracle业务表的数据发生增删改,该表的索引会写redo,undo吗?
裸辞—躺平—刷题—大厂(Android面试的几大技巧)









