aberro
Topic Author
Posts: 6
Joined: 03 Feb 2018, 20:33

Command derived from DependencyObject is not executing.

28 Jan 2022, 15:08

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;
	}
 
User avatar
sfernandez
Site Admin
Posts: 3363
Joined: 22 Dec 2011, 19:20

Re: Command derived from DependencyObject is not executing.

28 Jan 2022, 18:02

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?
 
User avatar
jsantos
Site Admin
Posts: 4822
Joined: 20 Jan 2012, 17:18
Contact:

Re: Command derived from DependencyObject is not executing.

01 Feb 2022, 10:51

Who is online

Users browsing this forum: No registered users and 7 guests