PageRenderTime 26ms CodeModel.GetById 19ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/V2.2/trunk/RI/Silverlight/StockTraderRI.Modules.Watch.Silverlight/WatchList/WatchListView.xaml.cs

#
C# | 43 lines | 20 code | 3 blank | 20 comment | 0 complexity | 8a3bbbecaee5a6a2f9a571dc96cd071a 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.Windows.Controls;
18using System.Windows.Data;
19using StockTraderRI.Infrastructure;
20
21namespace StockTraderRI.Modules.Watch.WatchList
22{
23    public partial class WatchListView : UserControl, IWatchListView
24    {
25        public WatchListView()
26        {
27            InitializeComponent();
28        }
29
30        public void SetModel(WatchListPresentationModel model)
31        {
32            this.DataContext = model;
33
34            // Because in Silverlight you cannot bind to a RelativeSource, we are using Resources with an observable value,
35            // in order to be able to bind to the Buy and Sell commands. 
36            // The resources are declared in the XAML, because Silverlight has StaticResource markup only, so these
37            // resources should be available when the control is initializing, even though the Value is yet not set.
38            Binding binding = new Binding("RemoveWatchCommand");
39            binding.Source = this.DataContext;
40            ((ObservableCommand)this.Resources["RemoveWatchCommand"]).SetBinding(ObservableCommand.ValueProperty, binding);
41        }
42    }
43}