为什么我没有在我的委托命令中收到参数?我已经在这个问题上存了好几天了,但仍然无法理解它,我对.NET框架相对较新。我正在使用MVVM和命令委托来获得点击按钮形状的x和Y坐标,就像一个圆圈。但是,我一直都在失败。如果可能的话,请帮助我。 这是我的看法
<Button Width="20"
Height="20"
Command="{Binding Path=DataContext.touchCommand,RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}">
这是我的观点模型
public class ViewModel : INotifyPropertyChanged
{
#region constructor plus member val
public event PropertyChangedEventHandler PropertyChanged;
public ObservableCollection<CartesianPoint> points { get; set; }
public ObservableCollection<CartesianPoint> missPoints { get; set; }
public DelegateCommand<CartesianPoint> SelectCommand { get; set; }
public CartesianPoint SelectedPoint { get; set; }
public ViewModel()
{
points = new ObservableCollection<CartesianPoint>();
missPoints = new ObservableCollection<CartesianPoint>();
this.testData();
}
private void InitializeCommands()
{
SelectCommand = new DelegateCommand<CartesianPoint>( (p) => SelectedPoint = p );
}
#endregion constructor plus member val
protected void OnPropertyChanged(String propertyName)
{
if( PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
Console.WriteLine( "from on propertity change");
}
public ICommand touchCommand
{
get
{
if (SelectCommand == null)
{
SelectCommand = new DelegateCommand<CartesianPoint>(( p) => Executed( p));
}
return SelectCommand;
}
}
public bool CanExecute()
{
return false;
}
public void Executed(object sender)
{
if (sender != null)
{
Console.WriteLine("this is a test");
CartesianPoint input = sender as CartesianPoint;
Console.WriteLine("{0} {1}"input.X, input.Y);
}
}
答案 0 :(得分:1)
那是因为您还没有指定/etc/logrotate.conf
值。