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