简体   繁体   English

无法与MVVM数据绑定Silverlight4 DataPager控件

[英]Unable to databind a Silverlight4 DataPager control with MVVM

I have a data driven Silverlight 4 business application with a fairly standard user interface. 我有一个数据驱动的Silverlight 4业务应用程序,具有相当标准的用户界面。 There's a side section that allows you to enter your search criteria, a standard Silverlight 4 datagrid control in another section that contains your search results (if any), and then a "details" section of the screen which shows the individual information of a single row of the grid when you click on it. 有一个侧面部分可以让您输入搜索条件,在另一个包含您的搜索结果(如果有)的部分中输入标准的Silverlight 4数据网格控件,然后在屏幕的“详细信息”部分显示单个广告的单个信息。单击它时的网格行。

Just underneath my grid control, I have placed a Silverlight DataPager control. 在网格控件的下面,我放置了一个Silverlight DataPager控件。 When my datagrid has databound search results, I want the DataPager control to be activated that lets you move forwards and backwards through the dataset. 当我的数据网格具有数据绑定搜索结果时,我希望激活DataPager控件,该控件使您可以在数据集中前后移动。

I've got the whole user interface xaml page bound to a custom viewmodel class. 我已经将整个用户界面xaml页面绑定到自定义viewmodel类。

My viewmodel class has a public ObservableCollection property called "Applications". 我的viewmodel类具有一个称为“应用程序”的公共ObservableCollection属性。 I then set the xaml of my datagrid control to bind to my Applications property: 然后,我将datagrid控件的xaml设置为绑定到我的Applications属性:

{datagrid:DataGrid x:Name="grid1" ItemsSource="{Binding Applications}"} {datagrid:DataGrid x:Name =“ grid1” ItemsSource =“ {绑定应用程序}”}

The datagrid control binds to my viewmodel with no issues. datagrid控件可以毫无问题地绑定到我的视图模型。 However, I'm unable to find the correct xaml syntax to bind the DataPager control to point to my same viewmodel Applications property. 但是,我找不到正确的xaml语法来绑定DataPager控件以指向我相同的viewmodel Applications属性。 So the end result is my DataPager control never activates and remains disabled. 因此,最终结果是我的DataPager控件从不激活并保持禁用状态。

I'm sure I'm missing something obvious, but hoping someone can send me a quick solution. 我确定我缺少明显的东西,但希望有人可以给我快速解决方案。

thanks in advance, John 预先感谢,约翰

原来,DataPager控件的xaml需要指向我的datagrid控件和ItemsSource的绑定路径:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM