我正嘗試創建在表單底部有一組字段和分頁按鈕的數據表單。WPF數據表格頁面
我希望分頁是一個單獨的控制與第一,上一個,下一個,最後一個標籤第1項。
此分頁控件將使用任何數據輸入表單,以允許用戶在前一記錄之間來回切換。例如,訂單,發票,付款是數據表單。顯示用戶選擇訂單,新訂單表單時的用戶。它也有分頁按鈕移動到前一個記錄。
我使用PagingItems的依賴屬性創建了一個名爲DataPager的UserControl。我希望這個依賴屬性是通用的,這樣我就可以通過一個項目列表(訂單,發票,付款)
爲此,我做了:在用戶控件中列出。我試圖在需要頁面的表單中綁定這個。
public List<object> Items
{
get { return (List<object>)GetValue(ItemsProperty); }
set { SetValue(ItemsProperty, value); }
}
// Using a DependencyProperty as the backing store for Items. This enables animation, styling, binding, etc...
public static readonly DependencyProperty ItemsProperty =
DependencyProperty.Register("Items", typeof(List<object>), typeof(DataPager), new UIPropertyMetadata(null, LoadItems));
private static void LoadItems(DependencyObject obj, DependencyPropertyChangedEventArgs e)
{
DataPager thisControl = (DataPager)obj;
thisControl.RefreshItems();
}
我得到在我使用的控制和綁定頁面以下錯誤:
System.Windows.Data Error: 1 : Cannot create default converter to perform 'one-way' conversions between types 'System.Collections.Generic.List`1[PagingSample.Order]' and 'System.Collections.Generic.List`1[System.Object]'. Consider using Converter property of Binding. BindingExpression:Path=Orders; DataItem='MainViewModel' (HashCode=26754911); target element is 'DataPager' (Name='dataPager1'); target property is 'Items' (type 'List`1')
System.Windows.Data Error: 5 : Value produced by BindingExpression is not valid for target property.; Value='System.Collections.Generic.List`1[PagingSample.Order]' BindingExpression:Path=Orders; DataItem='MainViewModel' (HashCode=26754911); target element is 'DataPager' (Name='dataPager1'); target property is 'Items' (type 'List`1')
不知道我怎麼能保持DataPager的控制項屬性是通用的。我還沒有想出如何告訴父控件CurrentItem顯示。
但想清除第一個障礙。任何幫助讚賞。
謝謝阿迪。我現在也在查看CollectionView – isakavis