Command derived from DependencyObject is not executing.
As title says. If I remove DependencyObject from declaration, then command is executed.
In WPF this code runs as expected (command is executed).
Why do I need DependencyObject command? Because I'd prefer to use full featured binding, for some specific scenarios. Though, probably, I'll have to think of some workaround myself.
This post is mainly to highlight discrepancy in Noesis compared to WPF.
MainView.xaml:
Nothing special in MainView.xaml.cs, just the usual NoesisUnity.LoadComponent(this); and initialization of DataContext.
CommandProxy.cs:
In WPF this code runs as expected (command is executed).
Why do I need DependencyObject command? Because I'd prefer to use full featured binding, for some specific scenarios. Though, probably, I'll have to think of some workaround myself.
This post is mainly to highlight discrepancy in Noesis compared to WPF.
MainView.xaml:
Code: Select all
<UserControl x:Class="UI.MainView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:local="clr-namespace:UI"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance Type={x:Type local:MainViewModel}, IsDesignTimeCreatable=False}"
HorizontalAlignment="Left"
VerticalAlignment="Top"
HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch">
<Canvas HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<Button HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" >
<Button.Command>
<local:CommandProxy/>
</Button.Command>
Test button
</Button>
</Canvas>
</UserControl>
CommandProxy.cs:
Code: Select all
public class CommandProxy : ***DependencyObject***, ICommand
{
public bool CanExecute(object parameter) => true;
public void Execute(object parameter)
{
UnityEngine.Debug.Log("CommandProxy.Execute");
}
public event EventHandler CanExecuteChanged;
}-
-
sfernandez
Site Admin
- Posts: 3363
- Joined:
Re: Command derived from DependencyObject is not executing.
Unfortunately we don't support dependency object commands, the ICommand interface gets ignored when exposing the class to Noesis.
We should behave like WPF, because supporting this could be very useful. Could you please report it in our bugtracker?
We should behave like WPF, because supporting this could be very useful. Could you please report it in our bugtracker?
Who is online
Users browsing this forum: No registered users and 7 guests