This is a migrated thread and some comments may be shown as answers.

RadMaskedNumericInput not working with ApplicationCommands

9 Answers 150 Views
MaskedInput (Numeric, DateTime, Text, Currency)
This is a migrated thread and some comments may be shown as answers.
Hitesh
Top achievements
Rank 1
Hitesh asked on 20 Nov 2012, 06:21 PM
RadMaskedNumericInput not working with ApplicationCommands.paste.

it will show ApplicationCommands.paste value but it is not preserved.

onkeypress or tab change, it will change to old value and new paste value will never updated.

I also used CommandBindings in constructor of RadMaskedNumericInput. but it doesn't work.

CommandBindings.Add(

 

new CommandBinding(ApplicationCommands.Paste, (sender, e) =>

{

double inputValue;

bool isInputNumber = double.TryParse(Clipboard.GetText(), out inputValue);

this.Value = inputValue;

e.Handled = true;

}));

9 Answers, 1 is accepted

Sort by
0
Pavel R. Pavlov
Telerik team
answered on 23 Nov 2012, 04:58 PM
Hello Hitesh,

Thank you for bringing this issue to our attention. I have logged it as a bug in our PITS and you can follow and vote for it here. I also updated your Telerik account.

Kind regards,
Pavel R. Pavlov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Hitesh
Top achievements
Rank 1
answered on 23 Nov 2012, 05:43 PM
Pavel,

Thanks for response. is any workaround solution? since we have planned release next week, and would like to use applicationcommand feature for paste.
0
Petar Mladenov
Telerik team
answered on 28 Nov 2012, 11:44 AM
Hello Hitesh,

 We managed to create a workaround for the following configuration:

<telerik:RadToolBar >
            <telerik:RadButton Command="ApplicationCommands.Copy"  Content="Copy" x:Name="copyButton"/>
            <telerik:RadButton Command="ApplicationCommands.Paste" CommandTarget="{Binding ElementName=xNumericInput}" Content="Paste" x:Name="pasteButton"/>
        </telerik:RadToolBar>
 
        <TextBox />
        <telerik:RadMaskedNumericInput x:Name="xNumericInput"                                      
                                       IsClearButtonVisible="False"
                                       IsLastPositionEditable="False" />
Please note that the CommandTarget points to the MaskedNumericInput.
You have to create a CommandBinding like so:
<Window.CommandBindings>
       <CommandBinding Command="ApplicationCommands.Paste"
                 Executed="CommandBinding_Executed_1" />
   </Window.CommandBindings>
In the Executed handler we invoke the PasteCommand.Execute() method:
private void CommandBinding_Executed_1(object sender, ExecutedRoutedEventArgs e)
        {
            this.xNumericInput.PasteCommand.Execute(null);
            e.Handled = true;
        }
This is also demonstrated in the attached solution. Let us know if this is suitable for you.

Kind regards,
Petar Mladenov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Hitesh
Top achievements
Rank 1
answered on 28 Nov 2012, 03:52 PM
Hello Petar,

Thanks for response and demo project.

but it is restricting to only numeric control to paste value with CommandTarget property.

It should be flexible to paste value in multiple controls as well as any type of controls (Textbox, listbox, combobox, Radmaskednumeric).

Also i have created custom control (wrapper on Radmaskednumericinput control to specify default properties).

Please refer below code and inform how Applicationcommand.paste can be worked with all below controls.


MainWindow.xaml
----------------------------

<Window x:Class="WpfApplication5.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
        Title="MainWindow"
        Width="525"
        xmlns:local="clr-namespace:WpfApplication5"
        Height="350">
    <Window.CommandBindings>
        <CommandBinding Command="ApplicationCommands.Paste"
                  Executed="CommandBinding_Executed_1" />
    </Window.CommandBindings>
    <StackPanel >
  <telerik:RadToolBar >
            <telerik:RadButton Command="ApplicationCommands.Copy"  Content="Copy" x:Name="copyButton"/>
            <telerik:RadButton Command="ApplicationCommands.Paste" Content="Paste" x:Name="pasteButton"/>
  </telerik:RadToolBar>

        <TextBox Text="123" />
        <TextBox Text="456"/>
        <TextBox Text="789" />
        <TextBlock Height="20" Text="123456789"></TextBlock>
        <Label Content="1234"/>
        <local:FormattedNumericInput Width="50" />
        <local:FormattedNumericInput Width="50" />

    </StackPanel>
</Window>

FormatNumericControl.cs
-----------------------------------

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;

namespace WpfApplication5
{
    public class FormattedNumericInput : Telerik.Windows.Controls.RadMaskedNumericInput
    {
        #region Constructors

        public FormattedNumericInput()
        {
            AllowNegativeNumbers = false;
            IsClearButtonVisible = false;
            SelectionOnFocus = Telerik.Windows.Controls.SelectionOnFocus.DefaultSelectAll;
            Mask = "";
            FormatString = "0";
            SpinMode = Telerik.Windows.Controls.MaskedInput.SpinMode.None;
        }

        #endregion
    }
}

 

 

 

0
Hitesh
Top achievements
Rank 1
answered on 28 Nov 2012, 09:13 PM
I have setup below Commandbinding in my custom control constructor, but it is not calling. same is working with standard Textbox.


base
.CommandBindings.Add( new CommandBinding(ApplicationCommands.Paste,Paste_CanExecuteChanged))

0
Petar Mladenov
Telerik team
answered on 03 Dec 2012, 07:25 AM
Hello Hitesh,

 Currently we are not aware of a suitable workaround to match your requirements. We will try to fix the issue in our next Q1 Release. Thank you for your understanding.

Kind regards,
Petar Mladenov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Hitesh
Top achievements
Rank 1
answered on 17 Dec 2012, 02:14 PM
Hello Petar,
 
Please advise when is Q1 release date / fix will be ready to use?
0
Petar Mladenov
Telerik team
answered on 19 Dec 2012, 02:36 PM
Hi Hitesh,

 Q1 2013 is scheduled for the middle of February.

Regards,
Petar Mladenov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Hitesh
Top achievements
Rank 1
answered on 20 Dec 2012, 02:35 PM
Thanks Petar.

Tags
MaskedInput (Numeric, DateTime, Text, Currency)
Asked by
Hitesh
Top achievements
Rank 1
Answers by
Pavel R. Pavlov
Telerik team
Hitesh
Top achievements
Rank 1
Petar Mladenov
Telerik team
Share this question
or