PageRenderTime 47ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/V4/StockTrader RI/Silverlight/StockTraderRI.Modules.News.Silverlight/Article/ArticleView.xaml.cs

#
C# | 70 lines | 41 code | 4 blank | 25 comment | 2 complexity | a462558c13a15a3d6701c5c4a6663e75 MD5 | raw file
  1. //===================================================================================
  2. // Microsoft patterns & practices
  3. // Composite Application Guidance for Windows Presentation Foundation and Silverlight
  4. //===================================================================================
  5. // Copyright (c) Microsoft Corporation. All rights reserved.
  6. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
  7. // OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
  8. // LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  9. // FITNESS FOR A PARTICULAR PURPOSE.
  10. //===================================================================================
  11. // The example companies, organizations, products, domain names,
  12. // e-mail addresses, logos, people, places, and events depicted
  13. // herein are fictitious. No association with any real company,
  14. // organization, product, domain name, email address, logo, person,
  15. // places, or events is intended or should be inferred.
  16. //===================================================================================
  17. using System.ComponentModel.Composition;
  18. using System.Diagnostics.CodeAnalysis;
  19. using System.Windows;
  20. using System.Windows.Controls;
  21. using StockTraderRI.Infrastructure;
  22. using StockTraderRI.Modules.News.Controllers;
  23. namespace StockTraderRI.Modules.News.Article
  24. {
  25. [ViewExport(RegionName = RegionNames.ResearchRegion)]
  26. [PartCreationPolicy(CreationPolicy.NonShared)]
  27. public partial class ArticleView : UserControl
  28. {
  29. // Note - this import is here so that the controller is created and gets wired to the article and news reader
  30. // view models, which are shared instances
  31. [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1051:DoNotDeclareVisibleInstanceFields", Justification="This is public to avoid possible problems with MEF and partial trust.")]
  32. [Import]
  33. public INewsController newsController;
  34. public ArticleView()
  35. {
  36. InitializeComponent();
  37. }
  38. /// <summary>
  39. /// Sets the ViewModel.
  40. /// </summary>
  41. /// <remarks>
  42. /// This set-only property is annotated with the <see cref="ImportAttribute"/> so it is injected by MEF with
  43. /// the appropriate view model.
  44. /// </remarks>
  45. [Import]
  46. [SuppressMessage("Microsoft.Design", "CA1044:PropertiesShouldNotBeWriteOnly", Justification = "Needs to be a property to be composed by MEF")]
  47. public ArticleViewModel ViewModel
  48. {
  49. set
  50. {
  51. this.DataContext = value;
  52. }
  53. }
  54. private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
  55. {
  56. if (this.NewsList.SelectedItem != null)
  57. {
  58. VisualStateManager.GoToState(this, "Details", true);
  59. }
  60. else
  61. {
  62. VisualStateManager.GoToState(this, "List", true);
  63. }
  64. }
  65. }
  66. }