Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 29th, 2012  |  syntax: None  |  size: 2.29 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How to define behavior of a control in a separate .cs file (in WPF)?
  2. <Window x:Class="Modulated.MainWindow"
  3.     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  4.     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  5.     Title="MainWindow" Height="194" Width="525">
  6. <Grid>
  7.     <Button Content="Sort Asc" Height="23" HorizontalAlignment="Left" Margin="10,12,0,0" Name="button3" VerticalAlignment="Top" Width="75" Click="sort_asc" />
  8.     <Button Content="Sort Desc" Height="23" HorizontalAlignment="Left" Margin="12,42,0,0" Name="button4" VerticalAlignment="Top" Width="75" />
  9.     <ListBox Height="131" HorizontalAlignment="Left" Margin="99,12,0,0" Name="listBox1" VerticalAlignment="Top" Width="70" >
  10.         <ListBoxItem>1</ListBoxItem>
  11.         <ListBoxItem>2</ListBoxItem>
  12.         <ListBoxItem>3</ListBoxItem>
  13.     </ListBox>
  14.     <MediaElement Height="131" HorizontalAlignment="Left" Margin="187,12,0,0" Name="mediaElement1" VerticalAlignment="Top" Width="165" />
  15.     <Button Content="Play" Height="23" HorizontalAlignment="Left" Margin="372,12,0,0" Name="btnPlay" VerticalAlignment="Top" Width="75" Click="play" />
  16.     <Button Content="Stop" Height="23" HorizontalAlignment="Left" Margin="372,42,0,0" Name="btnStop" VerticalAlignment="Top" Width="75" Click="stop" />
  17.     <Button Content="Next" Height="23" HorizontalAlignment="Left" Margin="372,71,0,0" Name="btnNext" VerticalAlignment="Top" Width="75" Click="next" />
  18. </Grid>
  19.        
  20. using System;
  21. using System.Collections.Generic;
  22. using System.Linq;
  23. using System.Text;
  24. using System.Windows;
  25. using System.Windows.Controls;
  26. using System.Windows.Data;
  27. using System.Windows.Documents;
  28. using System.Windows.Input;
  29. using System.Windows.Media;
  30. using System.Windows.Media.Imaging;
  31. using System.Windows.Navigation;
  32. using System.Windows.Shapes;
  33.  
  34.  
  35. namespace Modulated
  36. {
  37. /// <summary>
  38. /// Interaction logic for MainWindow.xaml
  39. /// </summary>
  40. public partial class MainWindow : Window
  41. {
  42.     public MainWindow()
  43.     {
  44.         InitializeComponent();
  45.     }
  46.  
  47.     private void play(object sender, RoutedEventArgs e)
  48.     {
  49.         mediaElement1.Play();
  50.     }
  51.  
  52.     private void stop(object sender, RoutedEventArgs e)
  53.     {
  54.         mediaElement1.Stop();
  55.     }
  56.  
  57.     private void next(object sender, RoutedEventArgs e)
  58.     {}
  59.  
  60.     private void sort_asc(object sender, RoutedEventArgs e)
  61.     {}
  62. }
  63. }