1 | using System; |
---|
2 | using System.Collections.Generic; |
---|
3 | using System.Collections.ObjectModel; |
---|
4 | using System.Linq; |
---|
5 | using System.Text; |
---|
6 | using System.Threading.Tasks; |
---|
7 | using System.Windows; |
---|
8 | using System.Windows.Controls; |
---|
9 | using System.Windows.Data; |
---|
10 | using System.Windows.Documents; |
---|
11 | using System.Windows.Input; |
---|
12 | using System.Windows.Interop; |
---|
13 | using System.Windows.Media; |
---|
14 | using System.Windows.Media.Imaging; |
---|
15 | using System.Windows.Navigation; |
---|
16 | using System.Windows.Shapes; |
---|
17 | |
---|
18 | namespace WpfHarjoitus1 |
---|
19 | { |
---|
20 | /// <summary> |
---|
21 | /// Interaction logic for MainWindow.xaml |
---|
22 | /// </summary> |
---|
23 | public partial class MainWindow : Window |
---|
24 | { |
---|
25 | public ObservableCollection<string> listBoxItems { get; private set; } |
---|
26 | |
---|
27 | public MainWindow() |
---|
28 | { |
---|
29 | InitializeComponent(); |
---|
30 | listBoxItems = new ObservableCollection<string>(); |
---|
31 | DataContext = this; |
---|
32 | ClipboardListener.ClipboardUpdate += LisaaListaan; |
---|
33 | } |
---|
34 | |
---|
35 | private void LisaaListaan(string contents) |
---|
36 | { |
---|
37 | listBoxItems.Add(contents); |
---|
38 | } |
---|
39 | |
---|
40 | private async void listBox_SelectionChanged(object sender, SelectionChangedEventArgs e) |
---|
41 | { |
---|
42 | ClipboardListener.ClipboardUpdate -= LisaaListaan; |
---|
43 | //Clipboard.SetText(listBox.SelectedItem.ToString()); |
---|
44 | Clipboard.SetText(listBoxItems.ElementAt(listBox.SelectedIndex)); |
---|
45 | await Task.Delay(10); |
---|
46 | ClipboardListener.ClipboardUpdate += LisaaListaan; |
---|
47 | } |
---|
48 | } |
---|
49 | } |
---|