Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MultiComboBox 重写 SelectedItemTemplate 无法绑定SelectedItems内的属性 #598

Open
fangjiajiajia opened this issue Mar 2, 2025 · 2 comments · May be fixed by #600
Open

MultiComboBox 重写 SelectedItemTemplate 无法绑定SelectedItems内的属性 #598

fangjiajiajia opened this issue Mar 2, 2025 · 2 comments · May be fixed by #600
Assignees
Labels
enhancement New feature or request

Comments

@fangjiajiajia
Copy link

<u:MultiComboBox ItemsSource="{Binding Items}" SelectedItems="{Binding SelectedItems}">
<u:MultiComboBox.ItemTemplate>






</u:MultiComboBox.ItemTemplate>
<u:MultiComboBox.SelectedItemTemplate>





</u:MultiComboBox.SelectedItemTemplate>
</u:MultiComboBox>

SelectedItems 的集合为 public ObservableCollection SelectedItems { get; set; }
其中Info 为
public class Info : ViewModelBase
{
public string Name { get; set; } = string.Empty;
public string Age { get; set; }

}
编译时报错 Unable to resolve property or method of name 'Name' on type 'XamlX.TypeSystem.XamlPseudoType'. Line 33, position 20. 为什么呢?

@rabbitism rabbitism self-assigned this Mar 2, 2025
@rabbitism rabbitism added the enhancement New feature or request label Mar 2, 2025
@rabbitism
Copy link
Member

We forget to config SelectedItemTemplate. will be fixed in next release. As work around you can just assign a DataType for DataTemplate

            <u:MultiComboBox.SelectedItemTemplate>
                <DataTemplate x:DataType="yourns:Info">
                    <TextBlock Text="{Binding Name}"></TextBlock>
                </DataTemplate>
            </u:MultiComboBox.SelectedItemTemplate>

@fangjiajiajia
Copy link
Author

OK,Thanks,I Just Finished it By x:DataType.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants