RadMaskedNumericInput not working with ApplicationCommands

10 posts, 0 answers
  1. Hitesh
    Hitesh avatar
    16 posts
    Member since:
    Jul 2012

    Posted 20 Nov 2012 Link to this post

    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;

    }));

  2. Pavel R. Pavlov
    Admin
    Pavel R. Pavlov avatar
    1183 posts

    Posted 23 Nov 2012 Link to this post

    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.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Hitesh
    Hitesh avatar
    16 posts
    Member since:
    Jul 2012

    Posted 23 Nov 2012 Link to this post

    Pavel,

    Thanks for response. is any workaround solution? since we have planned release next week, and would like to use applicationcommand feature for paste.
  5. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 28 Nov 2012 Link to this post

    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.

  6. Hitesh
    Hitesh avatar
    16 posts
    Member since:
    Jul 2012

    Posted 28 Nov 2012 Link to this post

    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
        }
    }

     

     

     

  7. Hitesh
    Hitesh avatar
    16 posts
    Member since:
    Jul 2012

    Posted 28 Nov 2012 Link to this post

    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))

  8. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 03 Dec 2012 Link to this post

    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.

  9. Hitesh
    Hitesh avatar
    16 posts
    Member since:
    Jul 2012

    Posted 17 Dec 2012 Link to this post

    Hello Petar,
     
    Please advise when is Q1 release date / fix will be ready to use?
  10. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 19 Dec 2012 Link to this post

    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.

  11. Hitesh
    Hitesh avatar
    16 posts
    Member since:
    Jul 2012

    Posted 20 Dec 2012 Link to this post

    Thanks Petar.

Back to Top
UI for WPF is Visual Studio 2017 Ready