Created
September 2, 2015 12:26
-
-
Save anonymous/0ab6c7bf37c29538a3a3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Window x:Class="WpfApplication6.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"> | |
<Grid> | |
<StackPanel> | |
<ComboBox ItemsSource="{Binding C}" SelectedValue="{Binding S}"/> | |
<Button Click="ButtonBase_OnClick">B</Button> | |
<Button Click="ButtonBase_OnClick2">B2</Button> | |
</StackPanel> | |
</Grid> | |
</Window> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using System.Collections.ObjectModel; | |
using System.ComponentModel; | |
using System.Windows; | |
namespace WpfApplication6 | |
{ | |
public partial class MainWindow : Window, INotifyPropertyChanged | |
{ | |
private int s; | |
private IEnumerable<int> c = new ObservableCollection<int>(); | |
public MainWindow() | |
{ | |
InitializeComponent(); | |
this.DataContext = this; | |
} | |
public int S | |
{ | |
get { return s; } | |
set | |
{ | |
s = value; | |
if (this.PropertyChanged != null) | |
{ | |
this.PropertyChanged(this, new PropertyChangedEventArgs("S")); | |
} | |
} | |
} | |
public IEnumerable<int> C | |
{ | |
get { return c; } | |
set | |
{ | |
c = value; | |
if (this.PropertyChanged != null) | |
{ | |
this.PropertyChanged(this, new PropertyChangedEventArgs("C")); | |
} | |
} | |
} | |
public event PropertyChangedEventHandler PropertyChanged; | |
private void ButtonBase_OnClick(object sender, RoutedEventArgs e) | |
{ | |
S = 1; | |
} | |
private void ButtonBase_OnClick2(object sender, RoutedEventArgs e) | |
{ | |
C = new ObservableCollection<int> { 2, 3 }; | |
C = new ObservableCollection<int> { 1, 2 }; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment