C
C#2mo ago
edgarka_

Avalonia ListBox pass selected DataTemplate

I put a behavior under ListBox to respond on the item clicked, is there a way to pass selected list member to VM? The code is in the file here: https://paste.mod.gg/lapcinshlpan/0 (now it passes current one that is set in code)
BlazeBin - lapcinshlpan
A tool for sharing your source code with the world!
13 Replies
Buddy
Buddy2mo ago
Please prefer $paste
MODiX
MODiX2mo ago
If your code is too long, you can post to https://paste.mod.gg/, save, and copy the link into chat for others to see your shared code!
Buddy
Buddy2mo ago
as rarely people download files to actually help.
edgarka_
edgarka_2mo ago
Got it, thanks!
SWEETPONY
SWEETPONY2mo ago
edgarka_
edgarka_2mo ago
I don't think it helps, I suspect I need to add CommandParameter into InvokeCommandAction, but not sure what to pass there
SWEETPONY
SWEETPONY2mo ago
<ListBox SelectedItem="{MyItem}"> and MyItem can be used in viewmodel MyItem will be changed after each click thats what you asked for: * is there a way to pass selected list member to VM?*
edgarka_
edgarka_2mo ago
I did it, yet still no results
No description
SWEETPONY
SWEETPONY2mo ago
I found smth similar in my code
No description
SWEETPONY
SWEETPONY2mo ago
but anyway SelectedItem should work in my case it works well
edgarka_
edgarka_2mo ago
Okay, I managed to get somewhere with your example. Command and SourceObject was something new to me It wasn't working at first as my EventName was "SelectionChanged". Changing it to "Tapped" removes errors, but it seems like "Tapped" is for touch screens. Do you know where can I find EventNames as VS doesn't list them for me?
SWEETPONY
SWEETPONY2mo ago
GitHub
Avalonia.Xaml.Behaviors/src/Avalonia.Xaml.Interactions.Events at ma...
Port of Windows UWP Xaml Behaviors for Avalonia Xaml. - AvaloniaUI/Avalonia.Xaml.Behaviors
Want results from more Discord servers?
Add your server