icommand

Multiple command parameters wpf button object

戏子无情 提交于 2019-12-03 10:09:35
How can I send multiple parameters from Button in WPF ? I am able to send single parameter which is value of TextBox properly. Here is the code. XAML <TextBox Grid.Row="1" Height="23" HorizontalAlignment="Left" Margin="133,22,0,0" Name="textBox1" VerticalAlignment="Top" Width="120" /> <Button Content="Button" Grid.Row="1" Height="23" Command="{Binding Path=CommandClick}" CommandParameter="{Binding Text,ElementName=textBox1}" HorizontalAlignment="Left" Margin="133,62,0,0" Name="button1" VerticalAlignment="Top" Width="75" /> Code behind public ICommand CommandClick { get; set; } this

Bind a button to a command (Windows Phone 7.5)

旧城冷巷雨未停 提交于 2019-12-03 02:31:54
I'm working on my windows-phone app wich uses some simple data binding. I've allready created a app wich was based on the MvvM programming method.The app i'm curently working on also works by MvvM method. Because i want to keep my code behind as clean as possible i was looking for a way to make the "button click event" (wich normaly takes place in the codebehind page) take place in my viewmodel or mainviewmodel. I have searched the internet in need of a simple explanation for the Icommand interface because i believe thats the way to go. Problem with the explanations i found was that some of

WPF ListBox Commands within ListBoxItem MVVM Command Binding

拜拜、爱过 提交于 2019-12-02 16:13:04
问题 I have been trying to find a way to have command buttons within my ListBoxItem's of a ListBox control. I use MVVM and Command Binding to the DataContext via ICommand interface . I am unable to find a way to bind to the Views DataContext from within the ListBox ItemsSource . I continue to get a Command "Not Found" error . Can anyone help me understand how to accomplish this. I believe that it has something to do with the command binding path, but I am unsure. Any help or direction would be

WPF ListBox Commands within ListBoxItem MVVM Command Binding

橙三吉。 提交于 2019-12-02 10:59:10
I have been trying to find a way to have command buttons within my ListBoxItem's of a ListBox control. I use MVVM and Command Binding to the DataContext via ICommand interface . I am unable to find a way to bind to the Views DataContext from within the ListBox ItemsSource . I continue to get a Command "Not Found" error . Can anyone help me understand how to accomplish this. I believe that it has something to do with the command binding path, but I am unsure. Any help or direction would be great. The DataContext of items in a ListBox will be the item they represent. So if your ItemsSource is

ICommand CanExecuteChanged not updating

自古美人都是妖i 提交于 2019-12-02 00:00:55
I am trying for MVVM pattern basic level and got struck at ICommand CanExecute changed. I have XAML binding as follows: <ListBox ItemsSource="{Binding Contact.Addresses}" x:Name="AddressCollections" Height="152" SelectedValue="{Binding SelectedAddress}" DockPanel.Dock="Top" /> <Button Content="Add" Command="{Binding AddAddressCommand}" DockPanel.Dock="Top" /> <Button Content="Remove" Command="{Binding DeleteAddressCommand}" DockPanel.Dock="Bottom" /> Commands: Public Class DeleteCommand Implements ICommand Private method As Object Private methodname As String Public Sub New(ByVal Controlname

Handling a UserControl's DependencyProperty Command

久未见 提交于 2019-12-01 13:39:07
I am struggling with getting a WPF UserControl to update one of its DependencyProperty when a DependencyProperty Command is invoked. Here's a an example that can hopefully demonstrate what I am trying to achieve. Basically it's a user control with a button on it. When the button is clicked, I'd like to increment an integer ( MyValue ) using a command ( MyCommand ): User Control <UserControl x:Class="UserControl1" x:Name="root" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org

ICommand method execute parameter value

荒凉一梦 提交于 2019-12-01 12:59:05
I try to understand the ICommand from wpf. In my Event class I implement the ICommand and their methods. one method is the Execute: public void Execute(object parameter) { //Do something } now is my question: what value contains the parameter parameter from Execute ? That value depends on the value you pass to the command. like a sniplet: Command="{Binding CalculateCommand}" CommandParameter="LCM"/> Look here: Command Binding with Parameter Passing for more details. 来源: https://stackoverflow.com/questions/11187052/icommand-method-execute-parameter-value

Another implementation of WPF Event to Command (with problems)

风流意气都作罢 提交于 2019-12-01 11:28:36
I am looking at various implementations of hooking a ICommand up to a control's event. So for instance the GotFocus of a TextBox should call a GotFocusCommand in my View Model. I then got an idea to implement my own version (for my own learning) and it is working well, but I can only link one event to one command in the XAML. ( Basically I just use reflection to find the specified Event and then do a AddEventHandler that executes the command ) This works fine : <Button local:EventToCommand.Event="Click" local:EventToCommand.Command="{Binding TestCommand}" /> But this does not : <Button local

Handling a UserControl's DependencyProperty Command

旧巷老猫 提交于 2019-12-01 10:57:09
问题 I am struggling with getting a WPF UserControl to update one of its DependencyProperty when a DependencyProperty Command is invoked. Here's a an example that can hopefully demonstrate what I am trying to achieve. Basically it's a user control with a button on it. When the button is clicked, I'd like to increment an integer ( MyValue ) using a command ( MyCommand ): User Control <UserControl x:Class="UserControl1" x:Name="root" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

ICommand method execute parameter value

只愿长相守 提交于 2019-12-01 10:06:12
问题 I try to understand the ICommand from wpf. In my Event class I implement the ICommand and their methods. one method is the Execute: public void Execute(object parameter) { //Do something } now is my question: what value contains the parameter parameter from Execute ? 回答1: That value depends on the value you pass to the command. like a sniplet: Command="{Binding CalculateCommand}" CommandParameter="LCM"/> Look here: Command Binding with Parameter Passing for more details. 来源: https:/