Linked Questions

Popular Questions

WPF command parameter how to use

Asked by At

I want to have two kind of status**(SmallPay,Credit)**, but that is decided by previous UserControl(ItemDetail.xaml)

ItemDetail.xaml

<Border Background="#fb5106" CornerRadius="8" Cursor="Hand">
    <Border.InputBindings>
       <MouseBinding MouseAction="LeftClick" Command="{Binding Path=ClickPhoneNumberCommand}" CommandParameter="A"/>
    </Border.InputBindings>
    <TextBlock Text="SmallPay" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="White" FontSize="32" />
</Border>

<Border Grid.Column="2" Background="#e7001f" CornerRadius="8" Cursor="Hand">
    <Border.InputBindings>
        <MouseBinding MouseAction="LeftClick" Command="{Binding Path=ClickPhoneNumberCommand}" CommandParameter="B"/>
        </Border.InputBindings>
    <TextBlock Text="Credit" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="White" FontSize="32" />
</Border>

ViewModel.cs

public DelegateCommand ClickItemCommand
{
    get
    {
        return new DelegateCommand(delegate ()
        {
            SelectedPopupType = PopupTypes.ItemDetail;
                IsShowPopup = true;
        });
    }
}

public DelegateCommand ClickPhoneNumberCommand
{
    get
    {
        return new DelegateCommand(delegate ()
        {
            SelectedPopupType = PopupTypes.PhoneNumber;
            IsShowPopup = true;
        });
    }
}

Then I want to get the commandParameter in the UserControl opened by 'ClickPhoneNumberCommand'. But, I dont know how? Is there way without no ViewModel?

Related Questions