Page 1 of 1

Command derived from DependencyObject is not executing.

Posted: 28 Jan 2022, 15:08
by aberro
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:
<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>
Nothing special in MainView.xaml.cs, just the usual NoesisUnity.LoadComponent(this); and initialization of DataContext.
CommandProxy.cs:
	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;
	}

Re: Command derived from DependencyObject is not executing.

Posted: 28 Jan 2022, 18:02
by sfernandez
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?

Re: Command derived from DependencyObject is not executing.

Posted: 01 Feb 2022, 10:51
by jsantos