【发布时间】:2018-11-22 20:21:08
【问题描述】:
我在我的 .xaml 文件中使用了 Exceed IntegerUpDown 控件。我想将 IntegerUpDown 值绑定为按钮的 CommandParameter。
我没有任何代码隐藏文件,这是一个自定义控件 xaml 文件。所以我想通过只使用 xaml systax 来实现这一点。
<DockPanel>
<xctk:IntegerUpDown x:Name="ExtraExpressionValue" Increment="1" FormatString="N0" AllowSpin="True" Width="70" Watermark="Numeric" AllowTextInput="False" Minimum="0" Value="999"/>
<Button Style="{StaticResource ContextMenuButton}" Margin="5,0,0,0" Content="Add" Command="{Binding SetExtaExpressionValueCommand}" CommandParameter="{Binding ElementName=ExtraExpressionValue,Path=Value}"/>
</DockPanel>
以上是我的 xaml 代码。这将 0 返回到命令方法。
我的命令类如下,
public class DesignItemCommands
{
private ICommand setExtaExpressionValueCommand;
public ICommand SetExtaExpressionValueCommand => setExtaExpressionValueCommand ?? (setExtaExpressionValueCommand = new CommandHandler(SetExtaExpressionValue, canExecute));
private bool canExecute;
public DesignItemCommands()
{
canExecute = true;
}
private void SetExtaExpressionValue(object parameter)
{
//I need parameter here..
}
}
【问题讨论】:
-
能否请您发帖
ViewModel。我想看看你是如何创建Command -
@TomerAgmon1 我已经更新了这个问题。请检查
标签: c# xaml exceed integerupdown