PageRenderTime 23ms CodeModel.GetById 12ms app.highlight 5ms 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//===================================================================================
17using System.ComponentModel.Composition;
18using System.Diagnostics.CodeAnalysis;
19using System.Windows;
20using System.Windows.Controls;
21using StockTraderRI.Infrastructure;
22using StockTraderRI.Modules.News.Controllers;
23
24namespace StockTraderRI.Modules.News.Article
25{
26    [ViewExport(RegionName = RegionNames.ResearchRegion)]
27    [PartCreationPolicy(CreationPolicy.NonShared)]
28    public partial class ArticleView : UserControl
29    {
30        // Note - this import is here so that the controller is created and gets wired to the article and news reader
31        // view models, which are shared instances
32        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1051:DoNotDeclareVisibleInstanceFields", Justification="This is public to avoid possible problems with MEF and partial trust.")]
33        [Import]
34        public INewsController newsController;
35
36        public ArticleView()
37        {
38            InitializeComponent();
39        }
40
41        /// <summary>
42        /// Sets the ViewModel.
43        /// </summary>
44        /// <remarks>
45        /// This set-only property is annotated with the <see cref="ImportAttribute"/> so it is injected by MEF with
46        /// the appropriate view model.
47        /// </remarks>
48        [Import]
49        [SuppressMessage("Microsoft.Design", "CA1044:PropertiesShouldNotBeWriteOnly", Justification = "Needs to be a property to be composed by MEF")]
50        public ArticleViewModel ViewModel
51        {          
52            set
53            {
54                this.DataContext = value;
55            }
56        }
57
58        private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
59        {
60            if (this.NewsList.SelectedItem != null)
61            {
62                VisualStateManager.GoToState(this, "Details", true);
63            }
64            else
65            {
66                VisualStateManager.GoToState(this, "List", true);
67            }
68        }
69    }
70}