I have a ListView like this
<ListView x:Name="lview" SelectionMode="Multiple" SelectedItems="{x:Bind SelectedItems}">
</ListView>
with this code-behind:
public IList<object> SelectedItems
{
get => (IList<object>)GetValue(SelectedItemsProperty);
set => SetValue(SelectedItemsProperty, value);
}
public static readonly DependencyProperty SelectedItemsProperty =
DependencyProperty.Register("SelectedItems", typeof(IList<object>), typeof(MainPage),
new PropertyMetadata(null));
public MainPage()
{
this.InitializeComponent();
List<int> io = new List<int> { 111111, 222, 33333, 4444444 };
lview.ItemsSource = io;
}
Here I am trying to bind a dependency property (SelectedItems) to my listview. But this gives me an error
Error XDG0013 The property "SelectedItems" does not have an accessible setter.
What am I doing wrong here? Is it not possible to bind SelectedItems to a dependency property?