DataGrid won't detect CTRL + C
-
I have a WPF applicaiton where the MainWindow class have <Window.CommandBindings> and <Window.InputBindings> so I can use CTRL + X, CTRL + C and CTRL + V commands. The MainWindow contains a DataGrid where I want to select a row and copy the data in the row with the CTRL + C command. When a row is selected in the DataGrid the CTRL + C command stops working. CTRL + X and CTRL + V are still detected. I have managed to reproduce this problem. Just copy and paste the code below, it should compile and run on the go. Then do the following: Press either CTRL + X, CTRL + C or CTRL + V you will get a popup window saying what command was activated. Select a row in the DataGrid and then run CTRL + C. Nothing will happen. MainWindow.XAML code
<Setter Property="BorderThickness" Value="0" /> <Setter Property="FocusVisualStyle" Value="{x:Null}" />
MainWindow.cs code
-
I have a WPF applicaiton where the MainWindow class have <Window.CommandBindings> and <Window.InputBindings> so I can use CTRL + X, CTRL + C and CTRL + V commands. The MainWindow contains a DataGrid where I want to select a row and copy the data in the row with the CTRL + C command. When a row is selected in the DataGrid the CTRL + C command stops working. CTRL + X and CTRL + V are still detected. I have managed to reproduce this problem. Just copy and paste the code below, it should compile and run on the go. Then do the following: Press either CTRL + X, CTRL + C or CTRL + V you will get a popup window saying what command was activated. Select a row in the DataGrid and then run CTRL + C. Nothing will happen. MainWindow.XAML code
<Setter Property="BorderThickness" Value="0" /> <Setter Property="FocusVisualStyle" Value="{x:Null}" />
MainWindow.cs code
You are right that you won't get the
MessageBox
but it is handeling the copy command. Just add aTextBox
and perform a paste. So I think the event is set toe.Handled
before your event. -
You are right that you won't get the
MessageBox
but it is handeling the copy command. Just add aTextBox
and perform a paste. So I think the event is set toe.Handled
before your event.I'm confused about your answer: * What do you mean by "add a TextBox". * Why should I use a TextBox to solve this? * Where should I add a TextBox? * What has the paste command to do with this? I only want the CTRL + C command to be detected in the MainWindow when a row is selected in the DataGrid. This has nothing to do what I want to copy and when I want to paste it.
-
I'm confused about your answer: * What do you mean by "add a TextBox". * Why should I use a TextBox to solve this? * Where should I add a TextBox? * What has the paste command to do with this? I only want the CTRL + C command to be detected in the MainWindow when a row is selected in the DataGrid. This has nothing to do what I want to copy and when I want to paste it.
That's what I am trying to tell you. In your current code it is detected. When you press CTRL+C the grid row is being copied. The textbox is just for testing. After the copy you can past your grid row there and see for your self that a CRTL+C copy was made.
-
I have a WPF applicaiton where the MainWindow class have <Window.CommandBindings> and <Window.InputBindings> so I can use CTRL + X, CTRL + C and CTRL + V commands. The MainWindow contains a DataGrid where I want to select a row and copy the data in the row with the CTRL + C command. When a row is selected in the DataGrid the CTRL + C command stops working. CTRL + X and CTRL + V are still detected. I have managed to reproduce this problem. Just copy and paste the code below, it should compile and run on the go. Then do the following: Press either CTRL + X, CTRL + C or CTRL + V you will get a popup window saying what command was activated. Select a row in the DataGrid and then run CTRL + C. Nothing will happen. MainWindow.XAML code
<Setter Property="BorderThickness" Value="0" /> <Setter Property="FocusVisualStyle" Value="{x:Null}" />
MainWindow.cs code
What is your silverlight version ? Because in the version 3 is not possible only in the 4 and the next versions