HandyOrg / HandyControl

Contains some simple and commonly used WPF controls
https://handyorg.github.io/
MIT License
6.01k stars 1.02k forks source link

`hc:ListBoxAttach.SelectedItems` binding got `null` #1599

Closed GF-Huang closed 3 months ago

GF-Huang commented 3 months ago

Describe the bug

https://github.com/HandyOrg/HandyControl/assets/4510984/a7ecdee8-7ce4-42f8-86dd-7c45959c71a3

Steps to reproduce the bug

Codes to reproduce

<hc:Window ...>
  <hc:CheckComboBox VerticalAlignment="Center" HorizontalAlignment="Center" Width="300"
                    ItemsSource="{Binding DataList}" hc:ListBoxAttach.SelectedItems="{Binding SelectedDataItems}" />
</hc:Window>
public class RootViewModel : PropertyChangedBase {
    public IReadOnlyList<string> DataList { get; } = ["1", "2", "3"];

    public List<string> SelectedDataItems { get; set; } = [];
}

CheckComboBoxDemo.zip

Expected behavior

No response

Screenshots

No response

NuGet package version

HandyControl 3.5.1

IDE

Visual Studio 2022

Framework type

.Net 8.0

Windows version

Windows 11 23H2

Additional context

No response

GF-Huang commented 3 months ago

Solved by change List<string> SelectedDataItems to IList SelectedDataItems.

blackvon-sudo commented 1 month ago

Solved by change List<string> SelectedDataItems to IList SelectedDataItems.

It's not worked

GF-Huang commented 1 month ago

Solved by change List<string> SelectedDataItems to IList SelectedDataItems.

It's not worked

Make sure it is IList not IList<T>.