Click here to Skip to main content
15,912,294 members
Home / Discussions / WPF
   

WPF

 
AnswerRe: Problem connection database Silverlight project Pin
Mycroft Holmes31-Oct-14 13:38
professionalMycroft Holmes31-Oct-14 13:38 
QuestionWPF Navigation system Pin
Hi-I-am-Tang29-Oct-14 4:58
Hi-I-am-Tang29-Oct-14 4:58 
AnswerRe: DataTransferManager RT Only? Pin
Richard Deeming27-Oct-14 11:56
mveRichard Deeming27-Oct-14 11:56 
GeneralRe: DataTransferManager RT Only? Pin
Richard Deeming28-Oct-14 4:14
mveRichard Deeming28-Oct-14 4:14 
GeneralRe: DataTransferManager RT Only? Pin
Richard Deeming28-Oct-14 7:34
mveRichard Deeming28-Oct-14 7:34 
GeneralRe: DataTransferManager RT Only? Pin
Richard Deeming28-Oct-14 8:42
mveRichard Deeming28-Oct-14 8:42 
QuestionWPF MVVM VALIDATION Pin
Arun Karuvatta23-Oct-14 22:08
professionalArun Karuvatta23-Oct-14 22:08 
AnswerRe: WPF MVVM VALIDATION Pin
Pete O'Hanlon23-Oct-14 22:42
mvePete O'Hanlon23-Oct-14 22:42 
QuestionWPF or MVC 4 Problem? Pin
Kevin Marois18-Oct-14 17:38
professionalKevin Marois18-Oct-14 17:38 
AnswerRe: WPF or MVC 4 Problem? Pin
Richard Deeming20-Oct-14 1:51
mveRichard Deeming20-Oct-14 1:51 
RantWPF - Why? Pin
SteveHolle17-Oct-14 6:20
SteveHolle17-Oct-14 6:20 
GeneralRe: WPF - Why? Pin
Gerry Schmitz17-Oct-14 11:07
mveGerry Schmitz17-Oct-14 11:07 
GeneralRe: WPF - Why? Pin
RedDk17-Oct-14 11:29
RedDk17-Oct-14 11:29 
GeneralRe: WPF - Why? Pin
SteveHolle6-Nov-14 4:18
SteveHolle6-Nov-14 4:18 
GeneralRe: WPF - Why? Pin
Mycroft Holmes17-Oct-14 13:51
professionalMycroft Holmes17-Oct-14 13:51 
GeneralRe: WPF - Why? Pin
SteveHolle6-Nov-14 4:22
SteveHolle6-Nov-14 4:22 
GeneralRe: WPF - Why? Pin
Mycroft Holmes6-Nov-14 11:36
professionalMycroft Holmes6-Nov-14 11:36 
GeneralRe: WPF - Why? Pin
Gary R. Wheeler8-Nov-14 3:12
Gary R. Wheeler8-Nov-14 3:12 
GeneralRe: WPF - Why? Pin
Pete O'Hanlon11-Nov-14 20:46
mvePete O'Hanlon11-Nov-14 20:46 
QuestionProblem to synchronise two DataContext bound ComboBoxes Pin
Tom Rahav10-Oct-14 18:25
Tom Rahav10-Oct-14 18:25 
AnswerRe: Problem to synchronise two DataContext bound ComboBoxes Pin
Gerry Schmitz13-Oct-14 11:39
mveGerry Schmitz13-Oct-14 11:39 
GeneralRe: Problem to synchronise two DataContext bound ComboBoxes Pin
Tom Rahav13-Oct-14 14:39
Tom Rahav13-Oct-14 14:39 
QuestionDataGrid won't detect CTRL + C Pin
Mc_Topaz9-Oct-14 3:17
Mc_Topaz9-Oct-14 3:17 
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
XML
<Window x:Class="WpfApplication1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">

    <!-- Commands for hot keys -->
    <Window.CommandBindings>

        <!-- Source -->
        <!-- http://stackoverflow.com/questions/4682915/defining-menuitem-shortcuts -->

        <CommandBinding Command="Cut" Executed="btnCut_Click" />
        <CommandBinding Command="Copy" Executed="btnCopy_Click" />
        <CommandBinding Command="Paste" Executed="btnPaste_Click" />

    </Window.CommandBindings>

    <!-- Hot keys -->
    <Window.InputBindings>
        <KeyBinding Key="X" Modifiers="Control" Command="Cut" />
        <KeyBinding Key="C" Modifiers="Control" Command="Copy" />
        <KeyBinding Key="V" Modifiers="Control" Command="Paste" />
    </Window.InputBindings>

    <Grid>
        <DataGrid Name="dgPersons" HorizontalScrollBarVisibility="Auto" AutoGenerateColumns="False" IsReadOnly="True" SelectionMode="Extended" GridLinesVisibility="None" Background="White" Margin="75,59,35,104">

            <DataGrid.CellStyle>
                <Style TargetType="DataGridCell">
                    <Setter Property="BorderThickness" Value="0" />
                    <Setter Property="FocusVisualStyle" Value="{x:Null}" />
                </Style>
            </DataGrid.CellStyle>

            <DataGrid.Columns>
                
                <!-- Name -->
                <DataGridTextColumn Header="Name" Width="100" Binding="{Binding Name, Mode=OneTime}" />
                
            </DataGrid.Columns>
        </DataGrid>
    </Grid>
</Window>


MainWindow.cs code
C#
using System;
//using System.Collections.Generic;
using System.Collections.ObjectModel;
//using System.Linq;
//using System.Text;
using System.Windows;
//using System.Windows.Controls;
//using System.Windows.Data;
//using System.Windows.Documents;
using System.Windows.Input;
//using System.Windows.Media;
//using System.Windows.Media.Imaging;
//using System.Windows.Navigation;
//using System.Windows.Shapes;

namespace WpfApplication1
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        ObservableCollection<Person> persons = new ObservableCollection<Person>();

        public MainWindow()
        {
            InitializeComponent();

            Person person1 = new Person("Person1");
            Person person2 = new Person("Person2");
            Person person3 = new Person("Person3");

            persons.Add(person1);
            persons.Add(person2);
            persons.Add(person3);

            dgPersons.ItemsSource = persons;

        }

        private void btnCut_Click(object sender, ExecutedRoutedEventArgs e)
        {
            MessageBox.Show("CUT command activated");
        }

        private void btnCopy_Click(object sender, ExecutedRoutedEventArgs e)
        {
            MessageBox.Show("COPY command activated");
        }

        private void btnPaste_Click(object sender, ExecutedRoutedEventArgs e)
        {
            MessageBox.Show("PASTE command activated");
        }
    }

    public class Person
    {
        string name;

        public Person(string name)
        {
            this.name = name;
        }

        public string Name
        {
            get { return name; }
        }
    }
}


How do I get CTRL + C wrking when a row is selected in the DataGrid?
AnswerRe: DataGrid won't detect CTRL + C Pin
Vincent Beek9-Oct-14 15:23
Vincent Beek9-Oct-14 15:23 
QuestionRe: DataGrid won't detect CTRL + C Pin
Mc_Topaz9-Oct-14 20:08
Mc_Topaz9-Oct-14 20:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.