WPF 分页控件 依赖属性无法双向绑定 请高手指点
<lib:DataPager Grid.Row="2" Name="dataPager" PageSizeList="10,20,30" PageIndex="{Binding Path= NPageIndex,Mode=TwoWay}"
PageSize="{Binding Path= NPageSize,Mode=TwoWay}"
ItemsSource="{Binding Path= DataList,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
Total="{Binding Path= NTotal,Mode=TwoWay}" cm:Message.Attach="[Event PageChanged]=[dataPager_PageChanged($source, $eventArgs)]"/>
分页控件 依赖属性的定义
#region 依赖属性和事件
public int PageSize {
get { return (int)GetValue(PageSizeProperty); }
set { SetValue(PageSizeProperty, value); }
}
// Using a DependencyProperty as the backing store for PageSize. This enables animation, styling, binding, etc...
public static readonly DependencyProperty PageSizeProperty =
DependencyProperty.Register("PageSize", typeof(int), typeof(DataPager), new UIPropertyMetadata(10));
public int Total {
get { return (int)GetValue(TotalProperty); }
set { SetValue(TotalProperty, value); }
}
// Using a DependencyProperty as the backing store for Total. This enables animation, styling, binding, etc...
public static readonly DependencyProperty TotalProperty =
DependencyProperty.Register("Total", typeof(int), typeof(DataPager), new UIPropertyMetadata(0));
public int PageIndex {
get { return (int)GetValue(PageIndexProperty); }
set { SetValue(PageIndexProperty, value); }
}
// Using a DependencyProperty as the backing store for PageIndex. This enables animation, styling, binding, etc...
public static readonly DependencyProperty PageIndexProperty =
DependencyProperty.Register("PageIndex", typeof(int), typeof(DataPager), new UIPropertyMetadata(1));
public string PageSizeList {
get { return (string)GetValue(PageSizeListProperty); }
set { SetValue(PageSizeListProperty, value); }
}
// Using a DependencyProperty as the backing store for PageSizeList. This enables animation, styling, binding, etc...
public static readonly DependencyProperty PageSizeListProperty =
DependencyProperty.Register("PageSizeList", typeof(string), typeof(DataPager), new UIPropertyMetadata("5,10,20", (s, e) => {
DataPager dp = s as DataPager;
if (dp.PageSizeItems == null) dp.PageSizeItems = new List<int>();
else dp.PageSizeItems.Clear();
dp.RaisePropertyChanged("PageSizeItems");
}));
public IEnumerable<object> ItemsSource {
get { return (IEnumerable<object>)GetValue(ItemsSourceProperty); }
set { SetValue(ItemsSourceProperty, value); }
}
/// <summary>
/// ItemsSource数据源
/// </summary>
public static readonly DependencyProperty ItemsSourceProperty =
DependencyProperty.Register("ItemsSource", typeof(IEnumerable<object>), typeof(DataPager), new UIPropertyMetadata(null));
现在我在使用这个分页控件的时候 绑定ItemSource 的DataList 和 Total 都发生改变的 但是没有能触发依赖属性的更新。 请大神指点 WPF 控件 分页 Binding Path
补充:.NET技术 , C#