当前位置:网站首页>.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>
边栏推荐
猜你喜欢
随机推荐
3. Transactions [mysql advanced]
MySQL's InnoDB engine (6)
【8月9日活动预告】Prometheus峰会
关于数据中心的设计方案,数据中心网络规划设计
ctfshow SSTI 知识点总结
MySQL事务隔离级别
What is an MQTT gateway?What is the difference with traditional DTU?
Discussion on Chinese Fuzzy Retrieval in Databases
Ladies and gentlemen, oracle11g, cdc2.2, flink1.13.6, single-table incremental synchronization.Without adding data
.NET-7.WPF学习经验总结
腾讯云宋翔:Kubernetes集群利用率提升实践
关于数据库中的中文模糊检索探讨
个人博客系统
简单业务类
2022河南萌新联赛第(五)场:信息工程大学 J - AC自动机
PLSQL学习第四天
Basic use of Log4j2
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
排序二叉树代码
Deep understanding of the array