Open ghost1372 opened 1 year ago
@michael-hawker @niels9001
@ghost1372 can you clarify what you mean by "if i dont use SettingsExpander.Items everything is working normal, but if i use SettingsExpander.Items command is not working"?
Also, what version of WinUI 3 are you using?
This seems like it'd be an issue with scope and binding vs. specific to the control itself. Do you see the command has been bound to the property?
Can you setup a repro of the problem in the https://github.com/michael-hawker/WinUI2Plus3Template? And see if the same problem occurs in UWP as well? (@Arlodotexe we should link to this template in the issue template for folks)
@michael-hawker The SettingsExpander has four parts for placing items:
Items ItemsHeader ItemsFooter Content
Placing items in the ItemsHeader, ItemsFooter and Content works well, But placing items in the Items section does not work.
i am using latest version: 1.3.1 and today i tested with 1.3.2.
Do you see the command has been bound to the property?
Do you mean this?
this is a winui 3 sample repro.
i tested in uwp and is not working too.
I actually think ItemsRepeater
might be the culprit here.
I modified the repro to show the behavior difference between ItemsRepeater
and ItemsControl
:
<ItemsControl ItemsSource="{x:Bind ViewModel.Items}">
<ItemsControl.ItemTemplate>
<DataTemplate x:DataType="x:String">
<ComboBox Name="cmbTest1">
<ComboBoxItem Content="TextBlock" Tag="TextBlock" />
<ComboBoxItem Content="HyperLink" Tag="HyperLink" />
<i:Interaction.Behaviors>
<ic:EventTriggerBehavior EventName="SelectionChanged">
<ic:EventTriggerBehavior.Actions>
<ic:InvokeCommandAction Command="{Binding ElementName=PageRoot, Path=ViewModel.Test1Command}" CommandParameter="{Binding ElementName=cmbTest1}" />
</ic:EventTriggerBehavior.Actions>
</ic:EventTriggerBehavior>
</i:Interaction.Behaviors>
</ComboBox>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<ItemsRepeater Grid.Column="1" ItemsSource="{x:Bind ViewModel.Items}">
<ItemsRepeater.ItemTemplate>
<DataTemplate x:DataType="x:String">
<ComboBox Name="cmbTest1">
<ComboBoxItem Content="TextBlock" Tag="TextBlock" />
<ComboBoxItem Content="HyperLink" Tag="HyperLink" />
<i:Interaction.Behaviors>
<ic:EventTriggerBehavior EventName="SelectionChanged">
<ic:EventTriggerBehavior.Actions>
<ic:InvokeCommandAction Command="{Binding ElementName=PageRoot, Path=ViewModel.Test2Command}" CommandParameter="{Binding ElementName=cmbTest2}" />
</ic:EventTriggerBehavior.Actions>
</ic:EventTriggerBehavior>
</i:Interaction.Behaviors>
</ComboBox>
</DataTemplate>
</ItemsRepeater.ItemTemplate>
</ItemsRepeater>
And this is what happens:
I'm using {Binding ElementName=PageRoot, Path=ViewModel.XxxCommand}
because of the different scope.
The binding inside ItemsControl
works as intended, but the literally copypasted XAML, inside ItemsRepeater
, doesn't work at all.
@michael-hawker can you please fix this issue?
@leoshusar @ghost1372 Am I understanding correctly that this bug also appears in a standalone ItemsRepeater
vs. ItemsControl
?
If so, this seems to be an ItemsRepeater
bug - I'd recommend filing an issue in the WinUI repo (might be that there's an existing issue already, but couldn't find it).
Yes, I remember now, there is an issue for this that already exists in the WinUI repo here: https://github.com/microsoft/microsoft-ui-xaml/issues/560 (Also probably related: https://github.com/microsoft/microsoft-ui-xaml/issues/2508)
I'll post on the issue with a link to @leoshusar's great repro project, thanks!
Tnx @michael-hawker The mentioned issue is open since 2019! WASDK team works very fast!🤦♂️😖 Do we have to wait for the next years to solve this problem by the super fast WASDK team? Can't fix the problem yourself? Like changing ItemsRepeater?
@ghost1372 I've moved it to the top of our tracking list and will investigating raising with WinUI team. Looks like a number of folks up-voted my latest comment on it, but not the issue itself. Those help.
We spent a lot of time on this control and needed to use ItemsRepeater
for the required pattern, so we can't change that here.
Hi @michael-hawker https://github.com/microsoft/microsoft-ui-xaml/issues/560#issuecomment-2262693759 fixed and i tested it and ItemsRepeater/ItemsControl both worked fine with wasdk v1.6. however this issue still not working i upload a new sample (updated with wasdk v1.6)
Describe the bug
if we use MvvM Command in ComboBox and SettingsExpander.Items, The command is not executed.
Steps to reproduce
if i dont use SettingsExpander.Items everything is working normal, but if i use SettingsExpander.Items command is not working