Winforms中的DataContext [英] DataContext in Winforms

查看:89
本文介绍了Winforms中的DataContext的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好

我想在winforms中使用datacontext,就像在wpf中一样。我该如何使用它?

I want to use datacontext in winforms just as in wpf. How can i use it?

推荐答案

您好Haziqamjad,

Hi Haziqamjad,

来自以下MSDN文档:

From the following MSDN document:

FrameworkElement.DataContext
Property

此属性获取或设置参与数据绑定时元素的数据上下文。 

This property gets or sets the data context for an element when it participates in data binding. 

数据上下文是一个允许元素从其父元素继承有关用于绑定的数据源的信息的概念,以及绑定的其他特征,如路径。

Data context is a concept that allows elements to inherit information from their parent elements about the data source that is used for binding, as well as other characteristics of the binding, such as the path.

数据上下文可以直接设置为.NET对象,绑定可以评估该对象的属性。或者,您可以将数据上下文设置为DataSourceProvider对象。

Data context can be set directly to a .NET object, with the bindings evaluating to properties of that object. Alternatively, you can set the data context to a DataSourceProvider object.

此依赖项属性继承属性值。如果存在没有通过本地值或样式建立的DataContext的其他值的子元素,则属性系统会将值设置为
最近父元素的DataContext值,并指定此值。

This dependency property inherits property values. If there are child elements without other values for DataContext established through local values or styles, then the property system will set the value to be the DataContext value of the nearest parent element with this value assigned.

我担心Windows Forms应用程序不支持此属性,它用于某些基于XMAL的技术。

I'm afraid Windows Forms app does not support this property, it is used to some technologies based on XMAL.

问候,

Stanly


这篇关于Winforms中的DataContext的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆