问题标签 [objectdataprovider]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
1414 浏览

wpf - WPF 数据绑定 - DataGridComboBoxColumn 和 ObjectDataProvider

我正在尝试编写一个与数据库表匹配的 WPF 4.0 DataGrid,其中有两个条目,特别是 GroupID 和 SectionID ... GroupID 包含一组组,SectionID 应该从采用 {GroupID, SectionID} 的表构建键并返回部分信息。

使用 ObjectDataProvider 将 DataGridComboBoxColumn 绑定到组表以显示组名很容易,但考虑到我需要将项目的相关 GroupID 传递到 GetSections() 方法的事实,我无法弄清楚如何执行这些部分ObjectDataProvider 绑定到...

其他人解决了类似的问题吗?

0 投票
1 回答
7462 浏览

wpf - WPF Binding to a method with parameter inside HierarchicalDataTemplate

Is there any way to bind a value to a textblock that is obtained from a method. For example, I pass my Person object into the HierarchicalDataTemplate, from there I can access its Weight property. Now lets say I want to get the weight in mars, I would call the InMars method that takes a parameter of int EarthWeight . Now earthweight is going to change from Person to Person, how can this parameter be set every time?

0 投票
1 回答
862 浏览

wpf - DataTemplate 和 ObjectDataProvider 刷新问题

我在 WPF 数据网格(WPF 工具包)中编辑单元格模板时遇到问题。该模板是使用 ComboBox 构建的,并且 ComboBox 的 ItemsSource 在运行时加载。

这是平均代码...

现在,我有这个问题。

我必须在每行上使用不同的值更新 dataValuesProvider。然后我在 datagrid 的 selectionchanged 事件上插入了 dataValuesProvider (dataValuesProvider=null) 的重置。

(dataValuesProvider 将在选定行的特定单元格上输入后加载)。

这就是问题所在:当我重置 dataValuesProvider(在新行的 selectionchanged 上)时,它修改了 ComboBox 的 SelectedValue 并且清除了前一行的 Property1。

我认为存在这种行为是因为单元格的编辑模板在我编辑单元格之前不会更新绑定关联。这是正确的?

我该怎么做才能避免这个问题?

0 投票
1 回答
1531 浏览

wpf - Can MethodParameters in an ObjectDataProvider be databound to other controls?

I've been exploring WPF and XAML for a while now, but have hit a slight stumbling block revolving around binding to a method.

My situation is:

There is a ComboBox bound to a DataTable. There is a ListBox bound to the return value of a method (GetDates) via an ObjectDataProvider. One of the input parameters of the method GetDates is an Id stored in the ComboBox/DataTable.

How can I bind a MethodParameter in the ObjectDataProvider to a particular value of the SelectedItem of a ComboBox (in this case, the SelectedItem is of type DataRowView)? Alternatively, am I missing a better way of solving this problem?

I can see ways out of it by using the code-behind, but I'd like to know if there's a more XAML-y solution. It's always useful to pick up little tips and tricks, even if it turns out not to be the best fix to this problem.

0 投票
1 回答
163 浏览

c# - 为什么我的 WPF 绑定不起作用?

我试图将列表绑定到列表框。在 Button1Click 方法中,MyClass 的新实例添加到我的 List<> 中,但在我的列表框中不可见。那里有我的代码:

这是我的表单集和 ObjectDataProvider:

我做错了什么?

0 投票
1 回答
1567 浏览

wpf - WPF 将作为 MethodParameter 选择的 MenuItem 传递给 ObjectDataProvider

我正在尝试将选定菜单项的文本/标题字符串作为 MethodParameter 传递给我的 ObjectDataProvider。我在 Internet 上看到过类似的示例,但无法将其专门用于菜单控件。我是 WPF 的新手,需要一些帮助来实现这一点。任何帮助将不胜感激。

下面是代码片段,ObjectDataProvider 的 XAML

菜单控件的 XAML

0 投票
1 回答
1254 浏览

wpf - 在 WPF 中的 ObjectDataProvider 中绑定参数的值

我希望能够这样做:

重点是

我无法解决这个问题。有任何想法吗?:(

0 投票
1 回答
1668 浏览

.net - 不需要 MVVM 中的 ObjectDataProvider?

我创建了一个简单的 MVVM,只有三个类 CashFlowView、CashFlowViewModel、CashFlowModel。

我使用基础架构的 9.1 XamDataPresenter(或 xamDataGrid)。

在我的 ViewModel 中:

ViewModel 通过以下方式连接到 View:

只要我将网格连接到 ObjectDataProvider,它就可以正常运行。但我希望我可以只连接到我的 ViewModel 中的一个属性。

根据 Infragistics,我所要做的就是:

但在这种情况下,我似乎需要绑定到另一个 ViewModel 的集合来表示我在网格中的行。这就是我感到困惑的地方。

我试过了,但它不起作用:

在 ViewModel 内部:

但是如何创建我的第二个 ViewModel (CashflowDataGridViewModel) ?

我尝试在第二个 ViewModel 中添加这个属性:

但我在视图中显示的只是“现金流”列标题,没有实际 cashflowModel 类的任何底层标题。

0 投票
4 回答
27947 浏览

wpf - 字符串属性与 Button.Content 的 WPF 绑定

我想将字符串属性与 Button.Content 绑定。

但为什么它没有工作?

数据类:

逻辑代码:

XAML:

0 投票
1 回答
2723 浏览

c# - WPF,在 XAML 的类中使用参数调用方法

我的ObjectDataProviderXAML 中有一个引用我的Window- 派生类中的方法。也就是说,我有NewForm.xaml.csclassNewForm并且ObjectDataProviderinNewForm.xaml引用了NewForm. 目前,使用以下 XAML,我收到堆栈溢出错误,因为NewForm构造函数不断被一遍又一遍地调用:

我猜这是因为ObjectType设置为NewForm,所以它加载NewForm以加载我的应用程序,但是它必须创建一个新实例NewForm才能调用GetTeamName,但是构造函数调用InitializeComponent它创建一个新的NewForm,它必须创建一个新NewForm的调用GetTeamName...它实际上每次都会使 Visual Studio 2010 崩溃。

无论如何,我要问的是我是否必须ObjectDataProvider在其他类中定义我的 XAML 通过 s 调用的方法?或者我可以以某种方式使用ObjectDataProvider我的 XAML 类中定义的方法吗?或者在我的 XAML 类中调用一个方法,我应该使用其他的 XAMLObjectDataProvider吗?似乎我不能将我的 C# 方法放在另一个类中,因为它用于从我的 XAMLTryFindResource中获取一个。XmlDataProvider