I'm working on a Xamarin.Forms project.
I have a behavior on a listview, which is doing a binding on a command with a converter. I did it with XAML and C# and it's working perfectly.
XAML part :
<ListView.Behaviors>
<bh:ListViewPagingBehavior
Command="{Binding LoadMoreLeadOfTheDateCommand}"
Converter="{StaticResource ItemVisibilityConverter}">
</bh:ListViewPagingBehavior>
</ListView.Behaviors>
But now i need to do this process on code-behind only, cause i needed to create my listview in the code-behind.
I tried to traduce this XAML like this :
ListViewPagingBehavior behavior = new ListViewPagingBehavior();
behavior.SetBinding(ListViewPagingBehavior.CommandProperty, "LoadMoreLeadOfTheDateCommand", BindingMode.Default, new ItemVisibilityEventArgsConverter());
myListView.Behaviors.Add(behavior);
Unfortunatly, the IValueConverter doesn't retrieve the same parameters as before on the Convert() method...
My Converter :
public class ItemVisibilityEventArgsConverter : IValueConverter
{
public object Convert (object value, Type targetType, object parameter, CultureInfo culture)
{
var eventArgs = value as ItemVisibilityEventArgs;
return eventArgs.Item;
}
public object ConvertBack (object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
Good parameters of Convert() with the working code :
value = Xamarin.Forms.ItemVisibilityEventArgs
targetType = System.Object
parameter = null
culture = null
Bad parameters of Convert() with my all C# code :
value = DelegateCommand
targetType = ICommand
parameter = null
culture = {fr-FR}
Can someone tell me where am i wrong ? Thanks a lot !