当前位置:网站首页>.NET-7.WPF learning experience summary
.NET-7.WPF learning experience summary
2022-08-10 06:55:00 【joyyi9】
系列文章目录
前言
The following few are familiar enough.
好好学习,落到实处.
参考链接:
- 官方文档
- WPF从零到1教程详解
- 系列文章(I have gained、Understanding data binding)
- 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);
//get control element
var srcButton = e.Source as Button;
var fe = (FrameworkElement) sender;
var fe2 = (FrameworkElement) args.Source;
//Simple binding of data
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>
边栏推荐
- Tencent Cloud Song Xiang: Kubernetes cluster utilization improvement practice
- Excuse me.Oracle CDC connector supports LogMiner and XStream API two ways to capture
- Everyone, the default configuration of oracle cdc occasionally takes 30 seconds to capture data. How to optimize this?
- CuteOneP is a PHP-based OneDrive multi-network disk mount program with member synchronization and other functions
- C语言文件操作
- 语法基础(判断语句)
- order by注入与limit注入,以及宽字节注入
- .NET-7.WPF学习经验总结
- 第2章 变量和基本类型读书笔记
- 【愚公系列】2022年08月 Go教学课程 034-接口和多态
猜你喜欢
随机推荐
761. Special Binary Sequences
2022河南萌新联赛第(五)场:信息工程大学 H - 小明喝奶茶
深入理解LTE网络的CDRX
2022 Henan Mengxin League Game (5): University of Information Engineering F - Split Turf
JS中初始化对象为null和空对象的区别
Please pay attention to me, thank you.
探索神经网络架构教程视频,设计神经网络的步骤
The constraints of the database learning table
Sort binary tree code
【愚公系列】2022年08月 Go教学课程 034-接口和多态
ES13 - ES2022 - The 123rd ECMA Congress approves the ECMAScript 2022 language specification
A few lines of code can crash the system;
COLMAP+OpenMVS realizes 3D reconstruction mesh model of objects
mysql数据库定时备份(保留近7天的备份)
数据库学习之数据类型
[Reinforcement Learning] "Easy RL" - Q-learning - CliffWalking (cliff walking) code interpretation
DGIOT支持工业设备租赁以及远程管控
[Network Security] Practice AWVS Range to reproduce CSRF vulnerability
自动化测试框架Pytest(三)——自定义allure测试报告
[网络安全]实操AWVS靶场复现CSRF漏洞