关于XAML,C#和WPF的更多思考的更多思考
来源:互联网 发布:网络远程教育怎么样 编辑:程序博客网 时间:2024/05/02 23:52
原文:More thoughts on more thoughts on XAML, C# and WPF
Charles在他的blog上,对我提出的关于WPF数据上下文和WPF可以忽略C#代码的阐述提出了疑问。
我也会尽我所能捍卫我的阐述。
具体来讲,我很少从DependencyOjbect继承对象,并且就从我观察到的来看,离开了它,XAML和WPF在数据绑定上运行的都还不错。
XAML所依赖的只是公有的可设置的属性和不带参数的公有的构造函数。单向的数据绑定也有类似的需求。
对于双向的数据绑定,如果你执行了旧的pre-WPF接口INotifyPropertyChanged,运行起来也很棒,并且这种绑定实现起来也特别不值一提。
下面是我写的一段C#代码,我希望通过它来说明这个问题:
string name;
bool lovesXaml;
public bool LovesXaml ...{
get ...{ return lovesXaml; }
set ...{ lovesXaml = value; Notify("LovesXaml"); }
}
public string Name ...{
get ...{ return name; }
set ...{ name = value; Notify("Name"); }
}
// boilerplate INotifyPropertyChanged code
void Notify(string name) ...{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(name));
}
public event PropertyChangedEventHandler PropertyChanged;
}
接下来是一个简单的WPF/XAML窗口,我们可以用一个DataTemplate来生成和编辑它:
xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'
xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'
xmlns:local='clr-namespace:Petzold'
Title='Petzold'
>
<ItemsControl>
<local:Author Name='Charles Petzold' LovesXaml='true'/>
>
<Window.Resources>
<DataTemplate DataType='{x:Type local:Author}'>
<StackPanel>
<StackPanel Orientation='Horizontal'>
原文:More thoughts on more thoughts on XAML, C# and WPF
Charles在他的blog上,对我提出的关于WPF数据上下文和WPF可以忽略C#代码的阐述提出了疑问。
我也会尽我所能捍卫我的阐述。
具体来讲,我很少从DependencyOjbect继承对象,并且就从我观察到的来看,离开了它,XAML和WPF在数据绑定上运行的都还不错。
XAML所依赖的只是公有的可设置的属性和不带参数的公有的构造函数。单向的数据绑定也有类似的需求。
对于双向的数据绑定,如果你执行了旧的pre-WPF接口INotifyPropertyChanged,运行起来也很棒,并且这种绑定实现起来也特别不值一提。
下面是我写的一段C#代码,我希望通过它来说明这个问题:
string name;
bool lovesXaml;
public bool LovesXaml ...{
get ...{ return lovesXaml; }
set ...{ lovesXaml = value; Notify("LovesXaml"); }
}
public string Name ...{
get ...{ return name; }
set ...{ name = value; Notify("Name"); }
}
// boilerplate INotifyPropertyChanged code
void Notify(string name) ...{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(name));
}
public event PropertyChangedEventHandler PropertyChanged;
}
接下来是一个简单的WPF/XAML窗口,我们可以用一个DataTemplate来生成和编辑它:
xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'
xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'
xmlns:local='clr-namespace:Petzold'
Title='Petzold'
>
<ItemsControl>
<local:Author Name='Charles Petzold' LovesXaml='true'/>
>
<Window.Resources>
<DataTemplate DataType='{x:Type local:Author}'>
<StackPanel>
<StackPanel Orientation='Horizontal'>
原文:More thoughts on more thoughts on XAML, C# and WPF
Charles在他的blog上,对我提出的关于WPF数据上下文和WPF可以忽略C#代码的阐述提出了疑问。
我也会尽我所能捍卫我的阐述。
具体来讲,我很少从DependencyOjbect继承对象,并且就从我观察到的来看,离开了它,XAML和WPF在数据绑定上运行的都还不错。
XAML所依赖的只是公有的可设置的属性和不带参数的公有的构造函数。单向的数据绑定也有类似的需求。
对于双向的数据绑定,如果你执行了旧的pre-WPF接口INotifyPropertyChanged,运行起来也很棒,并且这种绑定实现起来也特别不值一提。
下面是我写的一段C#代码,我希望通过它来说明这个问题:
string name;
bool lovesXaml;
public bool LovesXaml ...{
get ...{ return lovesXaml; }
set ...{ lovesXaml = value; Notify("LovesXaml"); }
}
public string Name ...{
get ...{ return name; }
set ...{ name = value; Notify("Name"); }
}
// boilerplate INotifyPropertyChanged code
void Notify(string name) ...{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(name));
}
public event PropertyChangedEventHandler PropertyChanged;
}
接下来是一个简单的WPF/XAML窗口,我们可以用一个DataTemplate来生成和编辑它:
xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'
xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'
xmlns:local='clr-namespace:Petzold'
Title='Petzold'
>
<ItemsControl>
<local:Author Name='Charles Petzold' LovesXaml='true'/>
>
<Window.Resources>
<DataTemplate DataType='{x:Type local:Author}'>
<StackPanel>
<StackPanel Orientation='Horizontal'>
原文:More thoughts on more thoughts on XAML, C# and WPF
Charles在他的blog上,对我提出的关于WPF数据上下文和WPF可以忽略C#代码的阐述提出了疑问。
我也会尽我所能捍卫我的阐述。
具体来讲,我很少从DependencyOjbect继承对象,并且就从我观察到的来看,离开了它,XAML和WPF在数据绑定上运行的都还不错。
XAML所依赖的只是公有的可设置的属性和不带参数的公有的构造函数。单向的数据绑定也有类似的需求。
对于双向的数据绑定,如果你执行了旧的pre-WPF接口INotifyPropertyChanged,运行起来也很棒,并且这种绑定实现起来也特别不值一提。
下面是我写的一段C#代码,我希望通过它来说明这个问题:
string name;
bool lovesXaml;
public bool LovesXaml ...{
get ...{ return lovesXaml; }
set ...{ lovesXaml = value; Notify("LovesXaml"); }
}
public string Name ...{
get ...{ return name; }
set ...{ name = value; Notify("Name"); }
}
// boilerplate INotifyPropertyChanged code
void Notify(string name) ...{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(name));
}
public event PropertyChangedEventHandler PropertyChanged;
}
接下来是一个简单的WPF/XAML窗口,我们可以用一个DataTemplate来生成和编辑它:
xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'
xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'
xmlns:local='clr-namespace:Petzold'
Title='Petzold'
>
<ItemsControl>
<local:Author Name='Charles Petzold' LovesXaml='true'/>
>
<Window.Resources>
<DataTemplate DataType='{x:Type local:Author}'>
<StackPanel>
<StackPanel Orientation='Horizontal'>
原文:More thoughts on more thoughts on XAML, C# and WPF
Charles在他的blog上,对我提出的关于WPF数据上下文和WPF可以忽略C#代码的阐述提出了疑问。
我也会尽我所能捍卫我的阐述。
具体来讲,我很少从DependencyOjbect继承对象,并且就从我观察到的来看,离开了它,XAML和WPF在数据绑定上运行的都还不错。
XAML所依赖的只是公有的可设置的属性和不带参数的公有的构造函数。单向的数据绑定也有类似的需求。
对于双向的数据绑定,如果你执行了旧的pre-WPF接口INotifyPropertyChanged,运行起来也很棒,并且这种绑定实现起来也特别不值一提。
下面是我写的一段C#代码,我希望通过它来说明这个问题:
string name;
bool lovesXaml;
public bool LovesXaml ...{
get ...{ return lovesXaml; }
set ...{ lovesXaml = value; Notify("LovesXaml"); }
}
public string Name ...{
get ...{ return name; }
set ...{ name = value; Notify("Name"); }
}
// boilerplate INotifyPropertyChanged code
void Notify(string name) ...{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(name));
}
public event PropertyChangedEventHandler PropertyChanged;
}
接下来是一个简单的WPF/XAML窗口,我们可以用一个DataTemplate来生成和编辑它:
xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'
xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'
xmlns:local='clr-namespace:Petzold'
Title='Petzold'
>
<ItemsControl>
<local:Author Name='Charles Petzold' LovesXaml='true'/>
>
<Window.Resources>
<DataTemplate DataType='{x:Type local:Author}'>
<StackPanel>
<StackPanel Orientation='Horizontal'>
- 关于XAML,C#和WPF的更多思考的更多思考
- 关于XAML,C#和WPF的更多思考的更多思考
- 关于XAML,C#和WPF的更多思考的更多思考
- 关于XAML,C#和WPF的更多思考的更多思考
- 关于XAML,C#和WPF的更多思考的更多思考
- 关于XAML,C#和WPF的更多思考的更多思考
- 关于XAML,C#和WPF的更多思考的更多思考
- 关于XAML,C#和WPF的更多思考的更多思考
- 关于XAML,C#和WPF的更多思考的更多思考
- 关于XAML,C#和WPF的更多思考的更多思考
- 关于XAML,C#和WPF的更多思考的更多思考
- 关于XAML,C#和WPF的更多思考的更多思考
- 关于XAML,C#和WPF的更多思考的更多思考
- 关于XAML,C#和WPF的更多思考的更多思考
- 成功--留给我们更多的是"思考".
- 对双向相关bean的更多思考
- 记住:模糊的思考,意味着更多的停留
- 实习更多的意义在于给你一个机会思考
- 工作流参考模型点评
- 关于James Clark的XML, JSON和其它许多事情
- .Net Framework 3.5(a.k.a "逆戟鲸") Beta 1
- OBE数据库配置过程
- OBE的下载与编译过程
- 关于XAML,C#和WPF的更多思考的更多思考
- 从Blog起名谈软件需求分析
- GET和人类 VS. 机器
- 最长不降子序nlogn 原理
- shark工作流源代码学习(四)
- Karl Rove和Dick Cheney加入了REST争论
- 在有限多的不大于100的正整数中,找出尽量多个相加起来值介于98~102之间的组合
- 总有更好的
- BouncyCastle JCE实践(三)