I have a comboxbox defined like this (basically):
<ComboBox x:Name="pageViewSize">
<ComboBox.Items>
<ComboBoxItem IsSelected="True">5</ComboBoxItem>
<ComboBoxItem>10</ComboBoxItem>
<ComboBoxItem>20</ComboBoxItem>
<ComboBoxItem>30</ComboBoxItem>
<ComboBoxItem>50</ComboBoxItem>
<ComboBoxItem>100</ComboBoxItem>
</ComboBox.Items>
</ComboBox>
Now i would like my DataPager's PageSize (which is the source to a DataGrid) be bound to this ComboBox's SelectedItem.Value (or is it SelectedValue?):
<DataPager PageSize="{Binding Path=SelectedItem.Value, ElementName=pageViewSize}" Source="{Binding PageView}"/>
This, unfortunately, is not working. The initial pagesize is not 10. And whenever i changed the selection in the ComboBox nothing happens to the displayed pagesize in the DataGrid.
What am i doing wrong?
Thanks
From DataPager.PageSize documentation:
The source typically implements the IPagedCollectionView interface. In this case, PageSize gets or sets the IPagedCollectionView.PageSize of the IPagedCollectionView.
If the source is a collection that implements IEnumerablebut not IPagedCollectionView, the DataPager ignores PageSize.
Maybe your data source doesn't properly support PageSize?
EDIT: I currently have the same issue as you I had the same issue as you, it was fixed by using @devdigital's answer.
I'm using data binding instead of element binding, on radio buttons + custom converter instead of combo, but it applies in the same way.
What I'm doing is data binding IsChecked
to a value in my View Model, with a custom two-way converter checking whether value is equal to converter's parameter.
So here is an example from one of my RadioButtons:
IsChecked="{Binding MyBindedValue, Converter={StaticResource EqualStringConverter}, ConverterParameter=5, Mode=TwoWay}"
And your DataPager
, modified:
<DataPager PageSize="{Binding MyBindedValue, Mode=TwoWay}" Source="{Binding PageView}"/>