Advertisement
Guest User

Untitled

a guest
Apr 17th, 2014
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.22 KB | None | 0 0
  1. public class MainViewModel : INotifyPropertyChanged
  2. {
  3. public MainViewModel()
  4. {
  5.  
  6. }
  7.  
  8. public event PropertyChangedEventHandler PropertyChanged;
  9. private void NotifyPropertyChanged(String propertyName)
  10. {
  11. PropertyChangedEventHandler handler = PropertyChanged;
  12. if (null != handler)
  13. {
  14. handler(this, new PropertyChangedEventArgs(propertyName));
  15. }
  16. if (propertyName=="BasicInfoText")
  17. {
  18. AdvancedInfoText = "Basic info updated";
  19. }
  20. if (propertyName=="AdvancedInfoText")
  21. {
  22. //do nothing
  23. }
  24. }
  25.  
  26. //text for the basic info
  27. public String BasicInfoText
  28. {
  29. get { return _basicInfoText; }
  30. set
  31. {
  32. if (_basicInfoText != value)
  33. {
  34. _basicInfoText = value;
  35. NotifyPropertyChanged("BasicInfoText");
  36. }
  37. }
  38. }
  39. private String _basicInfoText = "Initial text";
  40. //text for the advanced info
  41. public String AdvancedInfoText
  42. {
  43. get { return _advancedInfoText; }
  44. set
  45. {
  46. if (_advancedInfoText != value)
  47. {
  48. _advancedInfoText = value;
  49. NotifyPropertyChanged("AdvancedInfoText");
  50. }
  51. }
  52. }
  53. private String _advancedInfoText = "Initial Advance Text";
  54.  
  55. public class MainViewModel : INotifyPropertyChanged
  56. {
  57. public MainViewModel()
  58. {
  59.  
  60. this.PropertyChanged += MyViewModel_PropertyChanged;
  61. }
  62. //***********************************
  63. //catching events
  64. void MyViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e)
  65. {
  66. switch (e.PropertyName)
  67. {
  68. case "BasicSelected":
  69. {// Do something
  70. BasicInfoText = "basic text";
  71. break;
  72. }
  73. case "WideSelected":
  74. {// Do something
  75. BasicInfoText = "wide text";
  76. break;
  77. }
  78. case "NarrowSelected":
  79. {// Do something
  80. BasicInfoText = "narrow text";
  81. break;
  82. }
  83. case "ArtificalSelected":
  84. {// Do something
  85. BasicInfoText = "artificial text";
  86. break;
  87. }
  88. }
  89. }
  90.  
  91.  
  92. //***********************************
  93. //register handlers
  94. public event PropertyChangedEventHandler PropertyChanged;
  95. protected void OnPropertyChanged(PropertyChangedEventArgs e)
  96. {
  97. PropertyChangedEventHandler handler = PropertyChanged;
  98. if (handler != null)
  99. {
  100. handler(this, e);
  101. }
  102. }
  103.  
  104.  
  105. protected void OnPropertyChanged(String propertyName)
  106. {
  107. OnPropertyChanged(new PropertyChangedEventArgs(propertyName));
  108. }
  109.  
  110. //properties for the calculation and behavior
  111. public Boolean BasicSelected
  112. {
  113. get { return _basicSelected; }
  114. set {
  115. if (_basicSelected != value)
  116. {
  117. _basicSelected = value;
  118. OnPropertyChanged("BasicSelected");
  119. }
  120. }
  121. }
  122. public Boolean _basicSelected = true;
  123. //properties for the calculation and behavior
  124. public Boolean WideSelected
  125. {
  126. get { return _wideSelected; }
  127. set
  128. {
  129. if (_wideSelected != value)
  130. {
  131. _wideSelected = value;
  132. OnPropertyChanged("WideSelected");
  133. }
  134. }
  135. }
  136. public Boolean _wideSelected = false;
  137. //properties for the calculation and behavior
  138. public Boolean NarrowSelected
  139. {
  140. get { return _narrowSelected; }
  141. set
  142. {
  143. if (_narrowSelected != value)
  144. {
  145. _narrowSelected = value;
  146. OnPropertyChanged("NarrowSelected");
  147. }
  148. }
  149. }
  150. public Boolean _narrowSelected = false;
  151. //properties for the behavior test
  152. public Boolean ArtificalSelected
  153. {
  154. get { return _artificalSelected; }
  155. set
  156. {
  157. if (_artificalSelected != value)
  158. {
  159. _artificalSelected = value;
  160. OnPropertyChanged("ArtificalSelected");
  161. }
  162. }
  163. }
  164. public Boolean _artificalSelected = false;
  165. //text for the basic info
  166. public String BasicInfoText
  167. {
  168. get { return _basicInfoText; }
  169. set
  170. {
  171. if (_basicInfoText != value)
  172. {
  173. _basicInfoText = value;
  174. OnPropertyChanged("BasicInfoText");
  175. }
  176. }
  177. }
  178. public String _basicInfoText = "Initial text 2";
  179. //text for the advanced info
  180. public String AdvancedInfoText
  181. {
  182. get { return _advancedInfoText; }
  183. set
  184. {
  185. if (_advancedInfoText != value)
  186. {
  187. _advancedInfoText = value;
  188. OnPropertyChanged("AdvancedInfoText");
  189. }
  190. }
  191. }
  192. public String _advancedInfoText = "Initial Advance Text 2";
  193.  
  194. <phone:Panorama>
  195. <phone:Panorama.Title>
  196. <TextBlock Height="120" Text="Test visu" FontSize="110"/>
  197. </phone:Panorama.Title>
  198. <phone:PanoramaItem Header="Test selection" FontSize="22">
  199. <Grid >
  200. <Grid.RowDefinitions>
  201. <RowDefinition Height="70"/>
  202. <RowDefinition Height="auto"/>
  203. <RowDefinition Height="5"/>
  204. <RowDefinition Height="80"/>
  205. <RowDefinition Height="40"/>
  206. <RowDefinition Height="80"/>
  207. <RowDefinition Height="40"/>
  208. <RowDefinition Height="auto"/>
  209. </Grid.RowDefinitions>
  210. <Grid.ColumnDefinitions>
  211. <ColumnDefinition Width="49*"/>
  212. <ColumnDefinition Width="2*"/>
  213. <ColumnDefinition Width="49*"/>
  214. </Grid.ColumnDefinitions>
  215.  
  216. <TextBlock
  217. Name="InfoBasic"
  218. Text="{Binding BasicInfoText}"
  219. Grid.Row="0"
  220. Grid.ColumnSpan="3"
  221. HorizontalAlignment="Left"
  222. VerticalAlignment="Center"/>`
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement