admin管理员组文章数量:1022736
Hi recently i updated to 9 and suddenly i have problem with command binding which i did not have before.
Could someone explain me why this is working
var bt4 = new Button()
.Text("Confirm All")
.Center();
bt4.SetBinding(Button.CommandProperty, new Binding(nameof(vm.ConfirmAllAlarmsCommand),
mode: BindingMode.OneTime));
but this runs into error
var bt4 = new Button()
.Text("Confirm All")
.Center()
.Bind(Button.CommandProperty, getter: static (ActiveAlarmSummaryViewModel vm) =>
vm.ConfirmAllAlarmsCommand, mode: BindingMode.OneWay);
System.TypeLoadException: 'Method 'ApplyToResolvedSource' in type
'CommunityToolkit.Maui.Markup.TypedBinding`2' from assembly
'CommunityToolkit.Maui.Markup, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
does not have an implementation.'
I have quite standard view that have viewmodel injected in the constructor, and the command is a [RelayCommand] from toolkit
Hi recently i updated to 9 and suddenly i have problem with command binding which i did not have before.
Could someone explain me why this is working
var bt4 = new Button()
.Text("Confirm All")
.Center();
bt4.SetBinding(Button.CommandProperty, new Binding(nameof(vm.ConfirmAllAlarmsCommand),
mode: BindingMode.OneTime));
but this runs into error
var bt4 = new Button()
.Text("Confirm All")
.Center()
.Bind(Button.CommandProperty, getter: static (ActiveAlarmSummaryViewModel vm) =>
vm.ConfirmAllAlarmsCommand, mode: BindingMode.OneWay);
System.TypeLoadException: 'Method 'ApplyToResolvedSource' in type
'CommunityToolkit.Maui.Markup.TypedBinding`2' from assembly
'CommunityToolkit.Maui.Markup, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
does not have an implementation.'
I have quite standard view that have viewmodel injected in the constructor, and the command is a [RelayCommand] from toolkit
Share Improve this question asked Nov 19, 2024 at 10:48 Martin ZazvorkaMartin Zazvorka 778 bronze badges 01 Answer
Reset to default 1First of all, I can reproduce your problem with the nuget package CommunityToolkit.Maui.Markup
version 4.2.0. And when I downgrade the version to version 4.1.0, the Bind()
can work successfully.
Here is my code:
public MainPage(MyVM myVM)
{
InitializeComponent();
BindingContext = myVM;
var button = new Button()
.Text("Test")
.Center()
.Bind(Button.CommandProperty,getter:static(MyVM vm)=>vm.TestCommand,mode:BindingMode.OneWay);
layout.Children.Insert(0, button);
// there is <VerticalLayout x:Name="layout".../> in the xaml
}
Hi recently i updated to 9 and suddenly i have problem with command binding which i did not have before.
Could someone explain me why this is working
var bt4 = new Button()
.Text("Confirm All")
.Center();
bt4.SetBinding(Button.CommandProperty, new Binding(nameof(vm.ConfirmAllAlarmsCommand),
mode: BindingMode.OneTime));
but this runs into error
var bt4 = new Button()
.Text("Confirm All")
.Center()
.Bind(Button.CommandProperty, getter: static (ActiveAlarmSummaryViewModel vm) =>
vm.ConfirmAllAlarmsCommand, mode: BindingMode.OneWay);
System.TypeLoadException: 'Method 'ApplyToResolvedSource' in type
'CommunityToolkit.Maui.Markup.TypedBinding`2' from assembly
'CommunityToolkit.Maui.Markup, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
does not have an implementation.'
I have quite standard view that have viewmodel injected in the constructor, and the command is a [RelayCommand] from toolkit
Hi recently i updated to 9 and suddenly i have problem with command binding which i did not have before.
Could someone explain me why this is working
var bt4 = new Button()
.Text("Confirm All")
.Center();
bt4.SetBinding(Button.CommandProperty, new Binding(nameof(vm.ConfirmAllAlarmsCommand),
mode: BindingMode.OneTime));
but this runs into error
var bt4 = new Button()
.Text("Confirm All")
.Center()
.Bind(Button.CommandProperty, getter: static (ActiveAlarmSummaryViewModel vm) =>
vm.ConfirmAllAlarmsCommand, mode: BindingMode.OneWay);
System.TypeLoadException: 'Method 'ApplyToResolvedSource' in type
'CommunityToolkit.Maui.Markup.TypedBinding`2' from assembly
'CommunityToolkit.Maui.Markup, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
does not have an implementation.'
I have quite standard view that have viewmodel injected in the constructor, and the command is a [RelayCommand] from toolkit
Share Improve this question asked Nov 19, 2024 at 10:48 Martin ZazvorkaMartin Zazvorka 778 bronze badges 01 Answer
Reset to default 1First of all, I can reproduce your problem with the nuget package CommunityToolkit.Maui.Markup
version 4.2.0. And when I downgrade the version to version 4.1.0, the Bind()
can work successfully.
Here is my code:
public MainPage(MyVM myVM)
{
InitializeComponent();
BindingContext = myVM;
var button = new Button()
.Text("Test")
.Center()
.Bind(Button.CommandProperty,getter:static(MyVM vm)=>vm.TestCommand,mode:BindingMode.OneWay);
layout.Children.Insert(0, button);
// there is <VerticalLayout x:Name="layout".../> in the xaml
}
本文标签: netBinding Command using Community toolkit Markup problemStack Overflow
版权声明:本文标题:.net - Binding Command using Community toolkit Markup problem - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745567513a2156540.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论