Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MainViewModel : INotifyPropertyChanged
- {
- public MainViewModel()
- {
- }
- public event PropertyChangedEventHandler PropertyChanged;
- private void NotifyPropertyChanged(String propertyName)
- {
- PropertyChangedEventHandler handler = PropertyChanged;
- if (null != handler)
- {
- handler(this, new PropertyChangedEventArgs(propertyName));
- }
- if (propertyName=="BasicInfoText")
- {
- AdvancedInfoText = "Basic info updated";
- }
- if (propertyName=="AdvancedInfoText")
- {
- //do nothing
- }
- }
- //text for the basic info
- public String BasicInfoText
- {
- get { return _basicInfoText; }
- set
- {
- if (_basicInfoText != value)
- {
- _basicInfoText = value;
- NotifyPropertyChanged("BasicInfoText");
- }
- }
- }
- private String _basicInfoText = "Initial text";
- //text for the advanced info
- public String AdvancedInfoText
- {
- get { return _advancedInfoText; }
- set
- {
- if (_advancedInfoText != value)
- {
- _advancedInfoText = value;
- NotifyPropertyChanged("AdvancedInfoText");
- }
- }
- }
- private String _advancedInfoText = "Initial Advance Text";
- public class MainViewModel : INotifyPropertyChanged
- {
- public MainViewModel()
- {
- this.PropertyChanged += MyViewModel_PropertyChanged;
- }
- //***********************************
- //catching events
- void MyViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e)
- {
- switch (e.PropertyName)
- {
- case "BasicSelected":
- {// Do something
- BasicInfoText = "basic text";
- break;
- }
- case "WideSelected":
- {// Do something
- BasicInfoText = "wide text";
- break;
- }
- case "NarrowSelected":
- {// Do something
- BasicInfoText = "narrow text";
- break;
- }
- case "ArtificalSelected":
- {// Do something
- BasicInfoText = "artificial text";
- break;
- }
- }
- }
- //***********************************
- //register handlers
- public event PropertyChangedEventHandler PropertyChanged;
- protected void OnPropertyChanged(PropertyChangedEventArgs e)
- {
- PropertyChangedEventHandler handler = PropertyChanged;
- if (handler != null)
- {
- handler(this, e);
- }
- }
- protected void OnPropertyChanged(String propertyName)
- {
- OnPropertyChanged(new PropertyChangedEventArgs(propertyName));
- }
- //properties for the calculation and behavior
- public Boolean BasicSelected
- {
- get { return _basicSelected; }
- set {
- if (_basicSelected != value)
- {
- _basicSelected = value;
- OnPropertyChanged("BasicSelected");
- }
- }
- }
- public Boolean _basicSelected = true;
- //properties for the calculation and behavior
- public Boolean WideSelected
- {
- get { return _wideSelected; }
- set
- {
- if (_wideSelected != value)
- {
- _wideSelected = value;
- OnPropertyChanged("WideSelected");
- }
- }
- }
- public Boolean _wideSelected = false;
- //properties for the calculation and behavior
- public Boolean NarrowSelected
- {
- get { return _narrowSelected; }
- set
- {
- if (_narrowSelected != value)
- {
- _narrowSelected = value;
- OnPropertyChanged("NarrowSelected");
- }
- }
- }
- public Boolean _narrowSelected = false;
- //properties for the behavior test
- public Boolean ArtificalSelected
- {
- get { return _artificalSelected; }
- set
- {
- if (_artificalSelected != value)
- {
- _artificalSelected = value;
- OnPropertyChanged("ArtificalSelected");
- }
- }
- }
- public Boolean _artificalSelected = false;
- //text for the basic info
- public String BasicInfoText
- {
- get { return _basicInfoText; }
- set
- {
- if (_basicInfoText != value)
- {
- _basicInfoText = value;
- OnPropertyChanged("BasicInfoText");
- }
- }
- }
- public String _basicInfoText = "Initial text 2";
- //text for the advanced info
- public String AdvancedInfoText
- {
- get { return _advancedInfoText; }
- set
- {
- if (_advancedInfoText != value)
- {
- _advancedInfoText = value;
- OnPropertyChanged("AdvancedInfoText");
- }
- }
- }
- public String _advancedInfoText = "Initial Advance Text 2";
- <phone:Panorama>
- <phone:Panorama.Title>
- <TextBlock Height="120" Text="Test visu" FontSize="110"/>
- </phone:Panorama.Title>
- <phone:PanoramaItem Header="Test selection" FontSize="22">
- <Grid >
- <Grid.RowDefinitions>
- <RowDefinition Height="70"/>
- <RowDefinition Height="auto"/>
- <RowDefinition Height="5"/>
- <RowDefinition Height="80"/>
- <RowDefinition Height="40"/>
- <RowDefinition Height="80"/>
- <RowDefinition Height="40"/>
- <RowDefinition Height="auto"/>
- </Grid.RowDefinitions>
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="49*"/>
- <ColumnDefinition Width="2*"/>
- <ColumnDefinition Width="49*"/>
- </Grid.ColumnDefinitions>
- <TextBlock
- Name="InfoBasic"
- Text="{Binding BasicInfoText}"
- Grid.Row="0"
- Grid.ColumnSpan="3"
- HorizontalAlignment="Left"
- VerticalAlignment="Center"/>`
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement