Cut/Copy/Paste Commands WPF

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nelsonbrodyk
    New Member
    • Mar 2008
    • 81

    Cut/Copy/Paste Commands WPF

    Hey All, I am trying to implement buttons that follow the command pattern. .NET exposes ApplicationComm ands.Cut, copy and paste.

    I am trying the following:

    <Button Command="Applic ationCommands.C opy"/> //also have paste and cut.
    <TextBox Width="50"/>

    In the designer, selecting the textbox will eneable cut/copy. However when I run the application and go into the textbox and type, non the the buttons enable. Is this some sort of a focusing issue with the textbox?

    thanks!
  • sprasanna100
    New Member
    • Apr 2009
    • 2

    #2
    Hey, i have two buttons start and stop and only one will be enabled at any point of time. And i would like to use the same keygesture (something like Alt
    + P ) for both the commands. Is it possible?

    Comment

    • Meganutter
      New Member
      • Mar 2009
      • 47

      #3
      nelson are the buttons disabled to start with? if so you might want to try adding a TextChanged event to the textbox to enable or disable the buttons. something like
      Code:
              private void txtText_TextChanged(object sender, EventArgs e)
              {
                   if(txtText.Text.Trim != "")
                   {
                        btnCopy.Enabled = true;
                        btnCut.Enabled = true;
                   }
                   else
                   {
                        btnCopy.Enabled = false;
                        btnCut.Enabled = false;
                   }
              }

      Comment

      Working...