Skip to content

How do I Bind a Collection in Conjunction with WhenActivated Code-Behind #17736

Answered by IanRawley
FaithBeam asked this question in Q&A
Discussion options

You must be logged in to vote

I had a look and it is binding properly, but the ComboBox is failing to find a DataTemplate for the new child and so not presenting anything. If you manually set a DataTemplate like below everything shows up fine. I'm not sure why it's not falling back on the default template.

<ComboBox.ItemTemplate>
	<DataTemplate>
		<TextBlock Text="{Binding}"/>
	</DataTemplate>
</ComboBox.ItemTemplate>

There are multiple errors logged without the template.
DefaultViewLocator: Failed to resolve view for view model type 'System.Object'.
ViewModelViewHost: Couldn't find view for 'First'. Is it registered? Falling back to default content.

More Digging:
Avalonia implements a BindingHook that auto assigns t…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@FaithBeam
Comment options

@IanRawley
Comment options

Answer selected by FaithBeam
@FaithBeam
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants