Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

ViewModel convention, Blendability (opening xaml in Blend designer), …

…and remove conflicts with Silverlight 4.

ViewModel by convention
- ViewModel is found next to View by appending either Model or ViewModel suffix
  (Removed ModelType property)
- Convention can be overridden by [ViewModel] attribute applied to the View.cs

Removed Window and ViewUserControl and replaced with View. This removes conflict with Window in Silverlight 4.
- Correspondingly renamed WindowName on ApplicationContext to MainViewName and Window to MainView.

Samples update:
- Fixed weather sample (service call was no longer working)
- Add Default.aspx as a TOC.
  • Loading branch information...
commit 53b7284f49992e835df9ca44972ad37c15de1b23 1 parent df1ff9b
@nikhilk authored
Showing with 6,332 additions and 5,064 deletions.
  1. BIN  binaries/Debug/Server/SilverlightFX.Services.dll
  2. BIN  binaries/Debug/Server/SilverlightFX.Services.pdb
  3. BIN  binaries/Debug/Silverlight/SilverlightFX.dll
  4. BIN  binaries/Debug/Silverlight/SilverlightFX.pdb
  5. +2,850 −2,254 binaries/Debug/Silverlight/SilverlightFX.xml
  6. BIN  binaries/Release/Server/SilverlightFX.Services.dll
  7. BIN  binaries/Release/Server/SilverlightFX.Services.pdb
  8. BIN  binaries/Release/Silverlight/SilverlightFX.dll
  9. BIN  binaries/Release/Silverlight/SilverlightFX.pdb
  10. +2,850 −2,254 binaries/Release/Silverlight/SilverlightFX.xml
  11. +1 −1  samples/AmazonSearch/App.xaml
  12. +1 −1  samples/AmazonSearch/Views/SearchView.model.cs
  13. +4 −7 samples/AmazonSearch/Views/SearchView.xaml
  14. +1 −1  samples/AmazonSearch/Views/SearchView.xaml.cs
  15. +5 −5 samples/AmazonStore/AmazonStore.csproj
  16. +1 −1  samples/AmazonStore/StoreApplication.xaml
  17. +3 −3 samples/AmazonStore/Views/{MainWindow.Model.cs → MainView.Model.cs}
  18. +5 −5 samples/AmazonStore/Views/{MainWindow.xaml → MainView.xaml}
  19. +3 −3 samples/AmazonStore/Views/{MainWindow.xaml.cs → MainView.xaml.cs}
  20. +1 −1  samples/EffectControl/App.xaml
  21. +1 −1  samples/EffectsSample/App.xaml
  22. +3 −4 samples/Experiments/ActivityPage.xaml
  23. +1 −1  samples/Experiments/ActivityPage.xaml.cs
  24. +1 −1  samples/Experiments/App.xaml
  25. +3 −4 samples/Experiments/DataSourcePage.xaml
  26. +2 −1  samples/Experiments/DataSourcePage.xaml.cs
  27. +2 −5 samples/Experiments/DetailViewPage.xaml
  28. +2 −1  samples/Experiments/DetailViewPage.xaml.cs
  29. +1 −2  samples/Experiments/NumberEditForm.xaml.cs
  30. +3 −4 samples/Experiments/ParentPage.xaml
  31. +1 −1  samples/Experiments/ParentPage.xaml.cs
  32. +5 −7 samples/FlickrTiles/FlickrTiles.csproj
  33. +1 −1  samples/FlickrTiles/FlickrTilesApplication.xaml
  34. +6 −10 samples/FlickrTiles/Views/{MainWindow.xaml → MainView.xaml}
  35. +3 −3 samples/FlickrTiles/Views/{MainWindow.xaml.cs → MainView.xaml.cs}
  36. +4 −4 samples/FlickrTiles/Views/{MainWindowModel.cs → MainViewModel.cs}
  37. +5 −5 samples/News/News.csproj
  38. +1 −1  samples/News/NewsApplication.xaml
  39. +2 −2 samples/News/{NewsWindow.model.cs → NewsWidget.model.cs}
  40. +3 −3 samples/News/{NewsWindow.xaml → NewsWidget.xaml}
  41. +3 −3 samples/News/{NewsWindow.xaml.cs → NewsWidget.xaml.cs}
  42. +8 −2 samples/News/Views/News/ListPage.Model.cs
  43. +1 −1  samples/News/Views/News/ListPage.xaml
  44. +1 −1  samples/TaskList/TaskListApplication.xaml
  45. +1 −2  samples/TaskList/Views/EditTaskForm.xaml.cs
  46. +2 −6 samples/TaskList/Views/TaskListWidget.xaml
  47. +1 −1  samples/TaskList/Views/TaskListWidget.xaml.cs
  48. +1 −1  samples/ThemeSample/App.xaml
  49. +1 −1  samples/TwitFaves/App.xaml
  50. +3 −4 samples/TwitFaves/{MainWindow.xaml → MainView.xaml}
  51. +3 −3 samples/TwitFaves/{MainWindow.xaml.cs → MainView.xaml.cs}
  52. +3 −3 samples/TwitFaves/{MainWindowModel.cs → MainViewModel.cs}
  53. +4 −4 samples/TwitFaves/TwitFaves.csproj
  54. +1 −1  samples/WeatherWidget/App.xaml
  55. +2 −2 samples/WeatherWidget/Data/WeatherService.cs
  56. +4 −8 samples/WeatherWidget/Widget.xaml
  57. +1 −1  samples/WeatherWidget/Widget.xaml.cs
  58. BIN  samples/Web/Amazon/AmazonSearch.xap
  59. BIN  samples/Web/Amazon/AmazonStore.xap
  60. +70 −0 samples/Web/Default.aspx
  61. BIN  samples/Web/Effects/EffectControl.xap
  62. BIN  samples/Web/Effects/EffectsSample.xap
  63. BIN  samples/Web/Experiments/Experiments.xap
  64. BIN  samples/Web/Flickr/FlickrTiles.xap
  65. BIN  samples/Web/News/NewsWidget.xap
  66. BIN  samples/Web/TaskList/TaskList.xap
  67. BIN  samples/Web/Themes/ThemeSample.xap
  68. BIN  samples/Web/TwitFaves/TwitFaves.xap
  69. BIN  samples/Web/Weather/WeatherWidget.xap
  70. +1 −0  samples/Web/Web.csproj
  71. +94 −94 src/Client/Core/Applications/ApplicationContext.cs
  72. +2 −5 src/Client/Core/Core.csproj
  73. +1 −1  src/Client/Core/Data/ObjectDataSource.cs
  74. +1 −1  src/Client/Core/Themes/generic.xaml
  75. +1 −1  src/Client/Core/UserInterface/Actions/InvokeMemberAction.cs
  76. +4 −6 src/Client/Core/UserInterface/Actions/ShowForm.cs
  77. +1 −1  src/Client/Core/UserInterface/EventTriggerBase.cs
  78. +13 −23 src/Client/Core/UserInterface/Form.cs
  79. +33 −0 src/Client/Core/UserInterface/Interaction.cs
  80. +1 −1  src/Client/Core/UserInterface/ModelEventTrigger.cs
  81. +0 −16 src/Client/Core/UserInterface/Navigation/ErrorPage.cs
  82. +1 −26 src/Client/Core/UserInterface/Navigation/MvcPageLoader.cs
  83. +0 −16 src/Client/Core/UserInterface/Navigation/Page.cs
  84. +21 −21 src/Client/Core/UserInterface/Screen.cs
  85. +118 −0 src/Client/Core/UserInterface/View.cs
  86. +0 −38 src/Client/Core/UserInterface/ViewUserControl.cs
  87. +0 −43 src/Client/Core/UserInterface/Window.cs
  88. +4 −0 src/Client/Core/_System/ComponentModel/TypeTypeConverter.cs
  89. +0 −129 src/Client/Core/_System/Presentation/Controls/View.cs
  90. +150 −0 src/Client/Core/_System/Presentation/Controls/ViewModelAttribute.cs
  91. +1 −1  src/Client/Core/_System/Presentation/Interactivity/ScriptTriggerAction.cs
View
BIN  binaries/Debug/Server/SilverlightFX.Services.dll
Binary file not shown
View
BIN  binaries/Debug/Server/SilverlightFX.Services.pdb
Binary file not shown
View
BIN  binaries/Debug/Silverlight/SilverlightFX.dll
Binary file not shown
View
BIN  binaries/Debug/Silverlight/SilverlightFX.pdb
Binary file not shown
View
5,104 binaries/Debug/Silverlight/SilverlightFX.xml
2,850 additions, 2,254 deletions not shown
View
BIN  binaries/Release/Server/SilverlightFX.Services.dll
Binary file not shown
View
BIN  binaries/Release/Server/SilverlightFX.Services.pdb
Binary file not shown
View
BIN  binaries/Release/Silverlight/SilverlightFX.dll
Binary file not shown
View
BIN  binaries/Release/Silverlight/SilverlightFX.pdb
Binary file not shown
View
5,104 binaries/Release/Silverlight/SilverlightFX.xml
2,850 additions, 2,254 deletions not shown
View
2  samples/AmazonSearch/App.xaml
@@ -8,7 +8,7 @@
x:Class="AmazonSearch.App">
<Application.ApplicationLifetimeObjects>
- <fxapp:ApplicationContext x:Name="appContext" WindowName="AmazonSearch.Views.SearchView" />
+ <fxapp:ApplicationContext x:Name="appContext" MainViewName="AmazonSearch.Views.SearchView" />
</Application.ApplicationLifetimeObjects>
<Application.Resources>
View
2  samples/AmazonSearch/Views/SearchView.model.cs
@@ -8,7 +8,7 @@
namespace AmazonSearch.Views {
- public class SearchViewModel : Model {
+ public class SearchViewModel : ViewModel {
private ICatalog _catalog;
View
11 samples/AmazonSearch/Views/SearchView.xaml
@@ -1,14 +1,11 @@
-<fxui:Window x:Class="AmazonSearch.Views.SearchView"
+<fxui:View
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:fxaction="clr-namespace:SilverlightFX.UserInterface.Actions;assembly=SilverlightFX"
xmlns:fxui="clr-namespace:SilverlightFX.UserInterface;assembly=SilverlightFX"
xmlns:c="clr-namespace:AmazonSearch.Controls"
- xmlns:local="clr-namespace:AmazonSearch.Views">
-
- <fxui:Window.Model>
- <local:SearchViewModel />
- </fxui:Window.Model>
+ xmlns:local="clr-namespace:AmazonSearch.Views"
+ x:Class="AmazonSearch.Views.SearchView">
<Grid x:Name="LayoutRoot" Background="White">
<Grid.RowDefinitions>
@@ -46,4 +43,4 @@
</ItemsControl>
</Grid>
-</fxui:Window>
+</fxui:View>
View
2  samples/AmazonSearch/Views/SearchView.xaml.cs
@@ -7,7 +7,7 @@
namespace AmazonSearch.Views {
- public partial class SearchView : Window {
+ public partial class SearchView : View {
public SearchView() {
InitializeComponent();
View
10 samples/AmazonStore/AmazonStore.csproj
@@ -86,11 +86,11 @@
<Compile Include="Views\AboutForm.xaml.cs">
<DependentUpon>AboutForm.xaml</DependentUpon>
</Compile>
- <Compile Include="Views\MainWindow.Model.cs">
- <DependentUpon>MainWindow.xaml</DependentUpon>
+ <Compile Include="Views\MainView.Model.cs">
+ <DependentUpon>MainView.xaml</DependentUpon>
</Compile>
- <Compile Include="Views\MainWindow.xaml.cs">
- <DependentUpon>MainWindow.xaml</DependentUpon>
+ <Compile Include="Views\MainView.xaml.cs">
+ <DependentUpon>MainView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\ProductDetail.xaml.cs">
<DependentUpon>ProductDetail.xaml</DependentUpon>
@@ -127,7 +127,7 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
- <Page Include="Views\MainWindow.xaml">
+ <Page Include="Views\MainView.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
View
2  samples/AmazonStore/StoreApplication.xaml
@@ -14,7 +14,7 @@
</Application.Resources>
<Application.ApplicationLifetimeObjects>
- <fxapp:ApplicationContext x:Name="appContext" WindowName="MainWindow" ThemeName="Default">
+ <fxapp:ApplicationContext x:Name="appContext" MainViewName="MainView" ThemeName="Default">
<app:AmazonService />
</fxapp:ApplicationContext>
</Application.ApplicationLifetimeObjects>
View
6 samples/AmazonStore/Views/MainWindow.Model.cs → samples/AmazonStore/Views/MainView.Model.cs
@@ -1,4 +1,4 @@
-// MainWindow.model.cs
+// MainViewModel.model.cs
//
using System;
@@ -9,7 +9,7 @@
namespace Store {
- public class MainWindowModel : Model {
+ public class MainViewModel : ViewModel {
private Catalog _catalog;
private ShoppingCart _cart;
@@ -20,7 +20,7 @@ public class MainWindowModel : Model {
private Product _selectedProduct;
- public MainWindowModel(Catalog catalog, ShoppingCart cart, IExternalNavigationService navigationService) {
+ public MainViewModel(Catalog catalog, ShoppingCart cart, IExternalNavigationService navigationService) {
_catalog = catalog;
_catalog.ProductsLoaded += OnProductsLoaded;
_catalog.LoadPopularProducts();
View
10 samples/AmazonStore/Views/MainWindow.xaml → samples/AmazonStore/Views/MainView.xaml
@@ -1,4 +1,4 @@
-<fxui:Window
+<fxui:View
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dc="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"
@@ -7,11 +7,11 @@
xmlns:fxeffect="clr-namespace:SilverlightFX.UserInterface.Effects;assembly=SilverlightFX"
xmlns:fxtransition="clr-namespace:SilverlightFX.UserInterface.Transitions;assembly=SilverlightFX"
xmlns:app="clr-namespace:Store"
- x:Class="Store.MainWindow" ModelType="MainWindowModel">
+ x:Class="Store.MainView">
- <fxui:Window.Resources>
+ <fxui:View.Resources>
<app:ProductPriceFilterConverter x:Key="priceConverter" />
- </fxui:Window.Resources>
+ </fxui:View.Resources>
<fxui:XGrid Columns="20,*,5,350,20" Rows="20,40,*,5,250,20" Background="{StaticResource backgroundBrush}">
@@ -155,4 +155,4 @@
</fxui:TemplatePanel>
</fxui:XGrid>
-</fxui:Window>
+</fxui:View>
View
6 samples/AmazonStore/Views/MainWindow.xaml.cs → samples/AmazonStore/Views/MainView.xaml.cs
@@ -1,4 +1,4 @@
-// MainWindow.xaml.cs
+// MainView.xaml.cs
//
using System;
@@ -7,9 +7,9 @@
namespace Store {
- public partial class MainWindow : Window {
+ public partial class MainView : View {
- public MainWindow() {
+ public MainView() {
InitializeComponent();
}
}
View
2  samples/EffectControl/App.xaml
@@ -5,7 +5,7 @@
x:Class="EffectControl.App">
<Application.ApplicationLifetimeObjects>
- <fxapp:ApplicationContext x:Name="appContext" WindowName="Page" />
+ <fxapp:ApplicationContext x:Name="appContext" MainViewName="Page" />
</Application.ApplicationLifetimeObjects>
</Application>
View
2  samples/EffectsSample/App.xaml
@@ -6,6 +6,6 @@
x:Class="EffectsSample.App">
<Application.ApplicationLifetimeObjects>
- <fxapp:ApplicationContext x:Name="appContext" WindowName="Page" />
+ <fxapp:ApplicationContext x:Name="appContext" MainViewName="Page" />
</Application.ApplicationLifetimeObjects>
</Application>
View
7 samples/Experiments/ActivityPage.xaml
@@ -1,11 +1,10 @@
-<fxui:ViewUserControl
+<fxui:View
xmlns="http://schemas.microsoft.com/client/2007"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:fxui="clr-namespace:SilverlightFX.UserInterface;assembly=SilverlightFX"
xmlns:fxdata="clr-namespace:SilverlightFX.Data;assembly=SilverlightFX"
xmlns:fxaction="clr-namespace:SilverlightFX.UserInterface.Actions;assembly=SilverlightFX"
- x:Class="Experiments.ActivityPage"
- ModelType="Experiments.ActivityViewModel">
+ x:Class="Experiments.ActivityPage">
<Grid Background="White" Margin="20" HorizontalAlignment="Center">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
@@ -27,4 +26,4 @@
<Button Content="Error" fxui:Interaction.Action="$model.StopError()" />
</fxui:HStackPanel>
</Grid>
-</fxui:ViewUserControl>
+</fxui:View>
View
2  samples/Experiments/ActivityPage.xaml.cs
@@ -51,7 +51,7 @@ public class ActivityViewModel : ViewModel {
}
}
- public partial class ActivityPage : ViewUserControl {
+ public partial class ActivityPage : View {
public ActivityPage() {
InitializeComponent();
View
2  samples/Experiments/App.xaml
@@ -6,7 +6,7 @@
x:Class="Experiments.App">
<Application.ApplicationLifetimeObjects>
- <fxapp:ApplicationContext x:Name="appContext" WindowName="$page" />
+ <fxapp:ApplicationContext x:Name="appContext" MainViewName="$page" />
</Application.ApplicationLifetimeObjects>
<Application.Resources>
View
7 samples/Experiments/DataSourcePage.xaml
@@ -1,11 +1,10 @@
-<fxui:ViewUserControl
+<fxui:View
xmlns="http://schemas.microsoft.com/client/2007"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:fxui="clr-namespace:SilverlightFX.UserInterface;assembly=SilverlightFX"
xmlns:fxdata="clr-namespace:SilverlightFX.Data;assembly=SilverlightFX"
xmlns:fxaction="clr-namespace:SilverlightFX.UserInterface.Actions;assembly=SilverlightFX"
- x:Class="Experiments.DataSourcePage"
- ModelType="Experiments.DataViewModel">
+ x:Class="Experiments.DataSourcePage">
<Grid Background="White" Margin="20" HorizontalAlignment="Center">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="60" />
@@ -32,4 +31,4 @@
</fxdata:ObjectDataSource.QueryParameters>
</fxdata:ObjectDataSource>
</Grid>
-</fxui:ViewUserControl>
+</fxui:View>
View
3  samples/Experiments/DataSourcePage.xaml.cs
@@ -41,7 +41,8 @@ public class DataViewModel : ViewModel {
}
}
- public partial class DataSourcePage : ViewUserControl {
+ [ViewModel(typeof(DataViewModel))]
+ public partial class DataSourcePage : View {
public DataSourcePage() {
InitializeComponent();
View
7 samples/Experiments/DetailViewPage.xaml
@@ -1,4 +1,4 @@
-<fxui:Window
+<fxui:View
xmlns="http://schemas.microsoft.com/client/2007"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:fxui="clr-namespace:SilverlightFX.UserInterface;assembly=SilverlightFX"
@@ -7,9 +7,6 @@
xmlns:fxtransitions="clr-namespace:SilverlightFX.UserInterface.Transitions;assembly=SilverlightFX"
xmlns:app="clr-namespace:Experiments;assembly=Experiments"
x:Class="Experiments.DetailViewPage">
- <fxui:Window.Model>
- <app:ListModel />
- </fxui:Window.Model>
<StackPanel Background="White" Margin="20" HorizontalAlignment="Center">
@@ -71,4 +68,4 @@
</StackPanel>
</StackPanel>
-</fxui:Window>
+</fxui:View>
View
3  samples/Experiments/DetailViewPage.xaml.cs
@@ -90,7 +90,8 @@ public class ListModel : Model {
}
}
- public partial class DetailViewPage : Window {
+ [ViewModel(typeof(ListModel))]
+ public partial class DetailViewPage : View {
public DetailViewPage() {
InitializeComponent();
View
3  samples/Experiments/NumberEditForm.xaml.cs
@@ -35,8 +35,7 @@ public class NumberEditModel : TaskViewModel {
public partial class NumberEditForm : Form {
- public NumberEditForm(NumberEditModel model)
- : base(model) {
+ public NumberEditForm() {
InitializeComponent();
}
}
View
7 samples/Experiments/ParentPage.xaml
@@ -1,11 +1,10 @@
-<fxui:ViewUserControl
+<fxui:View
xmlns="http://schemas.microsoft.com/client/2007"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:fxui="clr-namespace:SilverlightFX.UserInterface;assembly=SilverlightFX"
xmlns:fxactions="clr-namespace:SilverlightFX.UserInterface.Actions;assembly=SilverlightFX"
xmlns:app="clr-namespace:Experiments;assembly=Experiments"
- x:Class="Experiments.ParentPage"
- ModelType="Experiments.ParentPageModel">
+ x:Class="Experiments.ParentPage">
<StackPanel Background="White" Margin="20" HorizontalAlignment="Center">
<StackPanel Orientation="Horizontal">
@@ -22,4 +21,4 @@
</StackPanel>
</StackPanel>
-</fxui:ViewUserControl>
+</fxui:View>
View
2  samples/Experiments/ParentPage.xaml.cs
@@ -32,7 +32,7 @@ public class ParentPageModel : ViewModel {
}
}
- public partial class ParentPage : ViewUserControl {
+ public partial class ParentPage : View {
public ParentPage() {
InitializeComponent();
View
12 samples/FlickrTiles/FlickrTiles.csproj
@@ -73,12 +73,10 @@
<DependentUpon>FlickrTilesApplication.xaml</DependentUpon>
</Compile>
<Compile Include="Views\ImageLoader.cs" />
- <Compile Include="Views\MainWindow.xaml.cs">
- <DependentUpon>MainWindow.xaml</DependentUpon>
- </Compile>
- <Compile Include="Views\MainWindowModel.cs">
- <DependentUpon>MainWindow.xaml</DependentUpon>
+ <Compile Include="Views\MainView.xaml.cs">
+ <DependentUpon>MainView.xaml</DependentUpon>
</Compile>
+ <Compile Include="Views\MainViewModel.cs" />
<Compile Include="Views\PhotoImage.cs" />
<Compile Include="Views\Progress.xaml.cs">
<DependentUpon>Progress.xaml</DependentUpon>
@@ -93,9 +91,9 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Content>
- <Page Include="Views\MainWindow.xaml">
+ <Page Include="Views\MainView.xaml">
+ <Generator>MSBuild:MarkupCompilePass1</Generator>
<SubType>Designer</SubType>
- <Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Progress.xaml">
<Generator>MSBuild:Compile</Generator>
View
2  samples/FlickrTiles/FlickrTilesApplication.xaml
@@ -5,7 +5,7 @@
x:Class="FlickrTiles.FlickrTilesApplication">
<Application.ApplicationLifetimeObjects>
- <fxapp:ApplicationContext x:Name="appContext" WindowName="FlickrTiles.Views.MainWindow" ThemeName="Default" />
+ <fxapp:ApplicationContext x:Name="appContext" MainViewName="FlickrTiles.Views.MainView" ThemeName="Default" />
</Application.ApplicationLifetimeObjects>
</Application>
View
16 samples/FlickrTiles/Views/MainWindow.xaml → samples/FlickrTiles/Views/MainView.xaml
@@ -1,4 +1,4 @@
-<fxui:Window
+<fxui:View
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:fxui="clr-namespace:SilverlightFX.UserInterface;assembly=SilverlightFX"
@@ -7,15 +7,11 @@
xmlns:fxtransitions="clr-namespace:SilverlightFX.UserInterface.Transitions;assembly=SilverlightFX"
xmlns:fxdata="clr-namespace:SilverlightFX.Data;assembly=SilverlightFX"
xmlns:app="clr-namespace:FlickrTiles.Views"
- x:Class="FlickrTiles.Views.MainWindow">
-
- <fxui:Window.Model>
- <app:MainWindowModel />
- </fxui:Window.Model>
+ x:Class="FlickrTiles.Views.MainView">
- <fxui:Window.Resources>
+ <fxui:View.Resources>
<fxdata:BooleanInverter x:Key="booleanInverter" />
- </fxui:Window.Resources>
+ </fxui:View.Resources>
<Grid Background="Black">
<Grid.ColumnDefinitions>
@@ -74,7 +70,7 @@
</fxui:HoverEffect>
</fxui:Interaction.Behaviors>
<Grid>
- <Image Source="{Binding Photo.ThumbnailUrl}" Width="75" Height="75" />
+ <Image Source="{Binding Thumbnail}" Width="75" Height="75" />
<app:Progress IsActive="{Binding IsImageLoading}" />
</Grid>
</Border>
@@ -135,4 +131,4 @@
</fxui:ContentView>
</Grid>
-</fxui:Window>
+</fxui:View>
View
6 samples/FlickrTiles/Views/MainWindow.xaml.cs → samples/FlickrTiles/Views/MainView.xaml.cs
@@ -1,4 +1,4 @@
-// MainWindow.xaml.cs
+// MainView.xaml.cs
//
using System;
@@ -7,9 +7,9 @@
namespace FlickrTiles.Views {
- public partial class MainWindow : Window {
+ public partial class MainView : View {
- public MainWindow() {
+ public MainView() {
InitializeComponent();
}
}
View
8 samples/FlickrTiles/Views/MainWindowModel.cs → samples/FlickrTiles/Views/MainViewModel.cs
@@ -1,4 +1,4 @@
-// MainWindowModel.cs
+// MainViewModel.cs
//
using System;
@@ -12,7 +12,7 @@
namespace FlickrTiles.Views {
- public class MainWindowModel : Model {
+ public class MainViewModel : ViewModel {
private IPhotoGallery _photoGallery;
@@ -23,11 +23,11 @@ public class MainWindowModel : Model {
private PhotoImage _selectedPhoto;
private bool _loadingImage;
- public MainWindowModel()
+ public MainViewModel()
: this(new FlickrService()) {
}
- internal MainWindowModel(IPhotoGallery photoGallery) {
+ internal MainViewModel(IPhotoGallery photoGallery) {
_photoGallery = photoGallery;
_photos = new ObservableCollection<PhotoImage>();
}
View
10 samples/News/News.csproj
@@ -70,11 +70,11 @@
<ItemGroup>
<Compile Include="Controllers\NewsController.cs" />
<Compile Include="Controllers\HomeController.cs" />
- <Compile Include="NewsWindow.model.cs">
- <DependentUpon>NewsWindow.xaml</DependentUpon>
+ <Compile Include="NewsWidget.model.cs">
+ <DependentUpon>NewsWidget.xaml</DependentUpon>
</Compile>
- <Compile Include="NewsWindow.xaml.cs">
- <DependentUpon>NewsWindow.xaml</DependentUpon>
+ <Compile Include="NewsWidget.xaml.cs">
+ <DependentUpon>NewsWidget.xaml</DependentUpon>
</Compile>
<Compile Include="Services\INewsService.cs" />
<Compile Include="Data\NewsItem.cs" />
@@ -109,7 +109,7 @@
<None Include="Properties\AppManifest.xml" />
</ItemGroup>
<ItemGroup>
- <Page Include="NewsWindow.xaml">
+ <Page Include="NewsWidget.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
View
2  samples/News/NewsApplication.xaml
@@ -12,7 +12,7 @@
</Application.Resources>
<Application.ApplicationLifetimeObjects>
- <fxapp:ApplicationContext x:Name="appContext" WindowName="NewsWindow" ThemeName="Default">
+ <fxapp:ApplicationContext x:Name="appContext" MainViewName="NewsWidget" ThemeName="Default">
<appsvc:TimesNewswireService />
</fxapp:ApplicationContext>
</Application.ApplicationLifetimeObjects>
View
4 samples/News/NewsWindow.model.cs → samples/News/NewsWidget.model.cs
@@ -1,4 +1,4 @@
-// NewsWindow.model.cs
+// NewsWidgetModel.model.cs
//
using System;
@@ -8,7 +8,7 @@
namespace NewsWidget {
- public sealed class NewsWindowModel : Model {
+ public sealed class NewsWidgetModel : Model {
private string _searchText;
View
6 samples/News/NewsWindow.xaml → samples/News/NewsWidget.xaml
@@ -1,11 +1,11 @@
-<fxui:Window
+<fxui:View
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:fxui="clr-namespace:SilverlightFX.UserInterface;assembly=SilverlightFX"
xmlns:fxaction="clr-namespace:SilverlightFX.UserInterface.Actions;assembly=SilverlightFX"
xmlns:fxnav="clr-namespace:SilverlightFX.UserInterface.Navigation;assembly=SilverlightFX"
xmlns:fxtransition="clr-namespace:SilverlightFX.UserInterface.Transitions;assembly=SilverlightFX"
- x:Class="NewsWidget.NewsWindow" ModelType="NewsWindowModel">
+ x:Class="NewsWidget.NewsWidget">
<fxui:XGrid Rows="10,Auto,10,Auto,10,*,10" Columns="4,*,4" Background="{StaticResource appBackground}">
<Image Grid.Column="1" Grid.Row="1" Width="300" Height="50"
@@ -57,4 +57,4 @@
</fxnav:PageFrame>
</fxui:XGrid>
-</fxui:Window>
+</fxui:View>
View
6 samples/News/NewsWindow.xaml.cs → samples/News/NewsWidget.xaml.cs
@@ -1,4 +1,4 @@
-// NewsWindow.xaml.cs
+// NewsWidget.xaml.cs
//
using System;
@@ -8,9 +8,9 @@
namespace NewsWidget {
- public partial class NewsWindow : Window {
+ public partial class NewsWidget : View {
- public NewsWindow() {
+ public NewsWidget() {
InitializeComponent();
}
}
View
10 samples/News/Views/News/ListPage.Model.cs
@@ -12,6 +12,7 @@ namespace NewsWidget.Views.News {
public class ListPageModel : Model {
private bool _filterToday;
+ private IEnumerable<NewsItem> _items;
public bool FilterToday {
get {
@@ -24,8 +25,13 @@ public class ListPageModel : Model {
}
public IEnumerable<NewsItem> Items {
- get;
- set;
+ get {
+ return _items;
+ }
+ set {
+ _items = value;
+ RaisePropertyChanged("Items", "ListItems");
+ }
}
public IEnumerable<NewsItem> ListItems {
View
2  samples/News/Views/News/ListPage.xaml
@@ -5,7 +5,7 @@
xmlns:fxeffect="clr-namespace:SilverlightFX.UserInterface.Effects;assembly=SilverlightFX"
xmlns:fxnav="clr-namespace:SilverlightFX.UserInterface.Navigation;assembly=SilverlightFX"
xmlns:fxaction="clr-namespace:SilverlightFX.UserInterface.Actions;assembly=SilverlightFX"
- x:Class="NewsWidget.Views.News.ListPage" ModelType="NewsWidget.Views.News.ListPageModel">
+ x:Class="NewsWidget.Views.News.ListPage">
<fxui:XGrid Rows="*,Auto">
<fxui:ListView Style="{StaticResource newsItemListStyle}" DataSource="{Binding ListItems}">
<fxui:ListView.ItemTemplate>
View
2  samples/TaskList/TaskListApplication.xaml
@@ -13,7 +13,7 @@
</Application.Resources>
<Application.ApplicationLifetimeObjects>
- <fxapp:ApplicationContext x:Name="appContext" WindowName="TaskListWidget" ThemeName="Default" />
+ <fxapp:ApplicationContext x:Name="appContext" MainViewName="TaskListWidget" ThemeName="Default" />
</Application.ApplicationLifetimeObjects>
</Application>
View
3  samples/TaskList/Views/EditTaskForm.xaml.cs
@@ -9,8 +9,7 @@ namespace TaskList {
public partial class EditTaskForm : Form {
- public EditTaskForm(EditTaskFormModel model)
- : base(model) {
+ public EditTaskForm() {
InitializeComponent();
}
}
View
8 samples/TaskList/Views/TaskListWidget.xaml
@@ -1,4 +1,4 @@
-<fxui:Window
+<fxui:View
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:c="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
@@ -8,10 +8,6 @@
x:Class="TaskList.TaskListWidget"
Width="300" Height="360">
- <fxui:Window.Model>
- <app:TaskListWidgetModel />
- </fxui:Window.Model>
-
<fxui:XGrid Columns="4,92,*,4" Rows="4,60,Auto,10,*,4">
<!-- Background -->
<Image Grid.ColumnSpan="4" Grid.RowSpan="6"
@@ -74,4 +70,4 @@
</fxui:ListView.ItemRemovedEffect>
</fxui:ListView>
</fxui:XGrid>
-</fxui:Window>
+</fxui:View>
View
2  samples/TaskList/Views/TaskListWidget.xaml.cs
@@ -7,7 +7,7 @@
namespace TaskList {
- public partial class TaskListWidget : Window {
+ public partial class TaskListWidget : View {
public TaskListWidget() {
InitializeComponent();
View
2  samples/ThemeSample/App.xaml
@@ -6,6 +6,6 @@
x:Class="ThemeSample.App">
<Application.ApplicationLifetimeObjects>
- <fxapp:ApplicationContext x:Name="appContext" ThemeName="$theme|Green" WindowName="$page|Page" />
+ <fxapp:ApplicationContext x:Name="appContext" ThemeName="$theme|Green" MainViewName="$page|Page" />
</Application.ApplicationLifetimeObjects>
</Application>
View
2  samples/TwitFaves/App.xaml
@@ -7,7 +7,7 @@
x:Class="TwitFaves.App">
<Application.ApplicationLifetimeObjects>
- <fxapp:ApplicationContext x:Name="appContext" WindowName="TwitFaves.MainWindow">
+ <fxapp:ApplicationContext x:Name="appContext" MainViewName="TwitFaves.MainView">
<data:TwitterService />
</fxapp:ApplicationContext>
</Application.ApplicationLifetimeObjects>
View
7 samples/TwitFaves/MainWindow.xaml → samples/TwitFaves/MainView.xaml
@@ -1,4 +1,4 @@
-<fxui:Window
+<fxui:View
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
@@ -6,8 +6,7 @@
xmlns:fxdata="clr-namespace:SilverlightFX.Data;assembly=SilverlightFX"
xmlns:fxui="clr-namespace:SilverlightFX.UserInterface;assembly=SilverlightFX"
mc:Ignorable="d"
- x:Class="TwitFaves.MainWindow"
- ModelType="TwitFaves.MainWindowModel"
+ x:Class="TwitFaves.MainView"
d:DesignWidth="800" d:DesignHeight="600"
FontFamily="Verdana" FontSize="12">
@@ -135,4 +134,4 @@
</fxui:XGrid>
</fxui:XGrid>
</fxui:XGrid>
-</fxui:Window>
+</fxui:View>
View
6 samples/TwitFaves/MainWindow.xaml.cs → samples/TwitFaves/MainView.xaml.cs
@@ -1,4 +1,4 @@
-// MainPage.xaml.cs
+// MainView.xaml.cs
//
using System;
@@ -8,9 +8,9 @@
namespace TwitFaves {
- public partial class MainWindow : Window {
+ public partial class MainView : View {
- public MainWindow() {
+ public MainView() {
InitializeComponent();
}
}
View
6 samples/TwitFaves/MainWindowModel.cs → samples/TwitFaves/MainViewModel.cs
@@ -1,4 +1,4 @@
-// MainWindowModel.cs
+// MainViewModel.cs
//
using System;
@@ -10,11 +10,11 @@
namespace TwitFaves {
- public class MainWindowModel : ViewModel {
+ public class MainViewModel : ViewModel {
private ITwitterService _twitterService;
- public MainWindowModel(ITwitterService twitterService) {
+ public MainViewModel(ITwitterService twitterService) {
_twitterService = twitterService;
}
View
8 samples/TwitFaves/TwitFaves.csproj
@@ -75,10 +75,10 @@
<Compile Include="Data\ITwitterService.cs" />
<Compile Include="Data\Tweet.cs" />
<Compile Include="Data\Profile.cs" />
- <Compile Include="MainWindow.xaml.cs">
- <DependentUpon>MainWindow.xaml</DependentUpon>
+ <Compile Include="MainView.xaml.cs">
+ <DependentUpon>MainView.xaml</DependentUpon>
</Compile>
- <Compile Include="MainWindowModel.cs" />
+ <Compile Include="MainViewModel.cs" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
@@ -94,7 +94,7 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
- <Page Include="MainWindow.xaml">
+ <Page Include="MainView.xaml">
<Generator>MSBuild:MarkupCompilePass1</Generator>
<SubType>Designer</SubType>
</Page>
View
2  samples/WeatherWidget/App.xaml
@@ -5,7 +5,7 @@
x:Class="WeatherWidget.App">
<Application.ApplicationLifetimeObjects>
- <fxapp:ApplicationContext x:Name="appContext" WindowName="Widget" ThemeName="Default" />
+ <fxapp:ApplicationContext x:Name="appContext" MainViewName="Widget" ThemeName="Default" />
</Application.ApplicationLifetimeObjects>
</Application>
View
4 samples/WeatherWidget/Data/WeatherService.cs
@@ -10,7 +10,7 @@ namespace WeatherWidget.Data {
public sealed class WeatherService {
- private const string ServiceUriFormat = "http://pipes.yahooapis.com/pipes/pipe.run?_id=WrXN95ta3RG3WFMqbrsjiw&zip={0}&_render=json";
+ private const string ServiceUriFormat = "http://pipes.yahooapis.com/pipes/pipe.run?_id=WrXN95ta3RG3WFMqbrsjiw&zip={0}&_render=json&random={1}";
private HttpWebRequest _request;
private string _zipCode;
@@ -18,7 +18,7 @@ public sealed class WeatherService {
public IAsyncResult BeginGetWeather(string zipCode, AsyncCallback callback, object state) {
_zipCode = zipCode;
- Uri uri = new Uri(String.Format(ServiceUriFormat, zipCode));
+ Uri uri = new Uri(String.Format(ServiceUriFormat, zipCode, DateTime.Now.Ticks));
_request = (HttpWebRequest)HttpWebRequest.Create(uri);
_request.Method = "GET";
View
12 samples/WeatherWidget/Widget.xaml
@@ -1,4 +1,4 @@
-<fxui:Window
+<fxui:View
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:fxui="clr-namespace:SilverlightFX.UserInterface;assembly=SilverlightFX"
@@ -10,14 +10,10 @@
x:Class="WeatherWidget.Widget"
Width="240" Height="240">
- <fxui:Window.Resources>
+ <fxui:View.Resources>
<fxglitz:ElasticInterpolation x:Key="ElasticOut" Mode="EaseOut" />
<fxglitz:ElasticInterpolation x:Key="ElasticInOut" Mode="EaseInOut" />
- </fxui:Window.Resources>
-
- <fxui:Window.Model>
- <app:WidgetModel />
- </fxui:Window.Model>
+ </fxui:View.Resources>
<Grid>
<Image Source="/Background.png" Width="240" Height="240" />
@@ -148,4 +144,4 @@
</Grid>
</Grid>
-</fxui:Window>
+</fxui:View>
View
2  samples/WeatherWidget/Widget.xaml.cs
@@ -8,7 +8,7 @@
namespace WeatherWidget {
- public partial class Widget : Window {
+ public partial class Widget : View {
public Widget() {
InitializeComponent();
View
BIN  samples/Web/Amazon/AmazonSearch.xap
Binary file not shown
View
BIN  samples/Web/Amazon/AmazonStore.xap
Binary file not shown
View
70 samples/Web/Default.aspx
@@ -0,0 +1,70 @@
+<%@ Page Language="C#" %>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" >
+<head>
+ <title>Silverlight.FX Samples</title>
+ <style type="text/css">
+ body { font-family: Segoe UI, Lucida Sans Unicode, Helvetica; font-size: 10pt; padding: 20px; }
+ h1 { font-size: 18pt; font-weight: normal; color: navy; }
+ h2 { font-size: 14pt; font-weight: bold; }
+ hr { height: 1px; clear: both; }
+ #logoImage { float: right; margin-right: 10px; margin-bottom: 10px; }
+ </style>
+</head>
+<body>
+ <img id="logoImage" src="http://projects.nikhilk.net/Content/Projects/SilverlightFX/Logo.png" />
+ <h1>Silverlight.FX Samples</h1>
+ <p>
+ This page provides lists all the samples distributed along with
+ <a href="http://projects.nikhilk.net/SilverlightFX">Silverlight.FX</a>
+ </p>
+ <p>Note that some samples access various web services, and require API keys. More on that below.</p>
+ <hr />
+ <h2>Applications</h2>
+ <dl>
+ <dt><a href="Amazon/AmazonSearch.aspx">Amazon Search</a></dt>
+ <dd>A simple Amazon search form. One of the early viewmodel samples.</dd>
+ <dt><a href="Amazon/AmazonStore.aspx">Amazon Store</a></dt>
+ <dd>A bigger Amazon sample. This looks up top deals, along with providing search and the ability to
+ populate your shopping cart, and completing the checkout process. The user interface demonstrates
+ layout animations, transitions etc.</dd>
+ <dt><a href="Flickr/FlickrTiles.aspx">Flickr Tiles</a></dt>
+ <dd>A Flickr search sample with thumbnails in an animated tile layout, and images shown with
+ exploding transitions.</dd>
+ <dt><a href="TaskList/TaskList.aspx">TaskList</a></dt>
+ <dd>A basic tasklist demonstrating view model and dialogs.</dd>
+ <dt><a href="News/NewsWidget.aspx">New York Times News Widget</a></dt>
+ <dd>A little widget using New York Times APIs to search and retrieve latest news articles.
+ Demonstrates view model along with navigation/MVC, as well as IoC.</dd>
+ <dt><a href="TwitFaves/TwitFaves.aspx">TwitFaves</a></dt>
+ <dd>A twitter app that pulls out hyperlinks from your Twitter favorites. Demonstrates using
+ ObjectDataSource along with your view model.</dd>
+ <dt><a href="Weather/WeatherSample.aspx">Weather Widget</a></dt>
+ <dd>A basic weather widget displaying current weather and forecast using zip code and
+ weather.com APIs. The sample demonstrates a number of declarative effects and transitions.</dd>
+ </dl>
+ <hr />
+ <h2>Miscellaneous/Feature-Specific Samples</h2>
+ <dl>
+ <dt><a href="Effects/EffectsSample.aspx">Effects and Transitions Gallery</a></dt>
+ <dd>Demonstrates various effects (fade, highlight, move, rotate, etc.) and transitions
+ (blinds, slide, cross fade etc.)</dd>
+ <dt><a href="Effects/EffectControl.aspx">Effects in a Custom Control</a></dt>
+ <dd>This sample demonstrates writing a control with an effect property, and an implemenation of a custom
+ effect similar to the FlashBulb effect in powerpoint.</dd>
+ <dt><a href="Themes/ThemeSample.aspx">Themes</a></dt>
+ <dd>A simple demonstration of themes.</dd>
+ <dt><a href="Experiments/TemplatePanelSample.aspx">TemplatePanel</a></dt>
+ <dd>Demo of TemplatePanel which allows you to create a layout with named placeholders.</dd>
+ </dl>
+ <hr />
+ <h2>API Keys</h2>
+ <p>Various samples use various web services, that require access keys. You will need to update
+ web.config with your own API keys. The following are the services that are in use:</p>
+ <ul>
+ <li>Amazon Web Services (<a href="http://aws.amazon.com/">http://aws.amazon.com/</a>)</li>
+ <li>Flickr (<a href="http://www.flickr.com/services/api/">http://www.flickr.com/services/api/</a>)</li>
+ <li>New York Times (<a href="http://developer.nytimes.com/docs/article_search_api">http://developer.nytimes.com/docs/article_search_api</a>)</li>
+ </ul>
+</body>
+</html>
View
BIN  samples/Web/Effects/EffectControl.xap
Binary file not shown
View
BIN  samples/Web/Effects/EffectsSample.xap
Binary file not shown
View
BIN  samples/Web/Experiments/Experiments.xap
Binary file not shown
View
BIN  samples/Web/Flickr/FlickrTiles.xap
Binary file not shown
View
BIN  samples/Web/News/NewsWidget.xap
Binary file not shown
View
BIN  samples/Web/TaskList/TaskList.xap
Binary file not shown
View
BIN  samples/Web/Themes/ThemeSample.xap
Binary file not shown
View
BIN  samples/Web/TwitFaves/TwitFaves.xap
Binary file not shown
View
BIN  samples/Web/Weather/WeatherWidget.xap
Binary file not shown
View
1  samples/Web/Web.csproj
@@ -82,6 +82,7 @@
<Content Include="Amazon\AmazonSearch.xap" />
<Content Include="Amazon\AmazonStore.aspx" />
<Content Include="Amazon\AmazonStore.xap" />
+ <Content Include="Default.aspx" />
<Content Include="Experiments\CityService.ashx" />
<Content Include="Experiments\ActivitySample.aspx" />
<Content Include="Experiments\FormattingSample.aspx" />
View
188 src/Client/Core/Applications/ApplicationContext.cs
@@ -50,14 +50,14 @@ public class ApplicationContext : IApplicationService, IApplicationLifetimeAware
private IDictionary<string, string> _startupArguments;
private string _themeName;
- private string _windowName;
+ private string _mainViewName;
private Style _screenStyle;
private IComponentContainer _componentContainer;
private ComponentCollection _components;
private Dictionary<Type, List<WeakDelegateReference>> _eventMap;
private object _model;
- private Window _mainWindow;
+ private View _mainView;
private bool _started;
/// <summary>
@@ -95,6 +95,34 @@ public class ApplicationContext : IApplicationService, IApplicationLifetimeAware
}
/// <summary>
+ /// Gets the top-level view associated with the application.
+ /// </summary>
+ public View MainView {
+ get {
+ return _mainView;
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets the type name of the top-level view. The name is used to instantiate
+ /// the top-level view on startup.
+ /// The name can be one of the following:
+ /// - A simple identifier which is treated as the name of a type alongside the application
+ /// - A namespace qualified type name treated as the name of a type in the application assembly
+ /// - An assembly qualified type name
+ /// - $initParamName|defaultName which allows the selection of a type name from the HTML page
+ /// </summary>
+ public string MainViewName {
+ get {
+ return _mainViewName ?? String.Empty;
+ }
+ set {
+ EnsureUnstarted();
+ _mainViewName = value;
+ }
+ }
+
+ /// <summary>
/// Gets or sets the application-wide model.
/// </summary>
public object Model {
@@ -184,34 +212,6 @@ public class ApplicationContext : IApplicationService, IApplicationLifetimeAware
}
}
- /// <summary>
- /// Gets the top-level window associated with the application.
- /// </summary>
- public Window Window {
- get {
- return _mainWindow;
- }
- }
-
- /// <summary>
- /// Gets or sets the type name of the top-level window. The name is used to instantiate
- /// the top-level window on startup.
- /// The name can be one of the following:
- /// - A simple identifier which is treated as the name of a type alongside the application
- /// - A namespace qualified type name treated as the name of a type in the application assembly
- /// - An assembly qualified type name
- /// - $initParamName|defaultName which allows the selection of a type name from the HTML page
- /// </summary>
- public string WindowName {
- get {
- return _windowName ?? String.Empty;
- }
- set {
- EnsureUnstarted();
- _windowName = value;
- }
- }
-
internal void EnsureUnstarted() {
if (_started) {
throw new InvalidOperationException("This property can only be set declaratively in XAML or in the Application's constructor.");
@@ -227,52 +227,17 @@ public class ApplicationContext : IApplicationService, IApplicationLifetimeAware
return null;
}
- private void InitializeTheme() {
- if (String.IsNullOrEmpty(_themeName)) {
- return;
- }
-
- string name = null;
-
- if (_themeName.StartsWith("$")) {
- string[] nameParts = _themeName.Split('|');
- if ((nameParts.Length > 2) || String.IsNullOrEmpty(nameParts[0])) {
- throw new InvalidOperationException("Invalid theme name. Either the name must be a simple name, or must be in the form $<ThemeInitParam>|<DefaultName>.");
- }
-
- if (nameParts.Length == 2) {
- name = nameParts[1];
- }
- if (_startupArguments != null) {
- string selectedName;
- string argName = nameParts[0].Substring(1);
- if (_startupArguments.TryGetValue(argName, out selectedName)) {
- name = selectedName;
- }
- }
- }
- else {
- name = _themeName;
- }
-
- if (String.IsNullOrEmpty(name)) {
- return;
- }
-
- Theme.LoadTheme(Application.Current.Resources, name);
- }
-
- private void InitializeWindow() {
- if (String.IsNullOrEmpty(_windowName)) {
+ private void InitializeMainView() {
+ if (String.IsNullOrEmpty(_mainViewName)) {
return;
}
string name = null;
- if (_windowName.StartsWith("$")) {
- string[] nameParts = _windowName.Split('|');
+ if (_mainViewName.StartsWith("$")) {
+ string[] nameParts = _mainViewName.Split('|');
if ((nameParts.Length > 2) || String.IsNullOrEmpty(nameParts[0])) {
- throw new InvalidOperationException("Invalid window name. Either the name must be a type name, or must be in the form $<WindowNameParam>|<DefaultName>.");
+ throw new InvalidOperationException("Invalid view name. Either the name must be a type name, or must be in the form $<MainViewNameParam>|<DefaultName>.");
}
if (nameParts.Length == 2) {
@@ -287,25 +252,25 @@ public class ApplicationContext : IApplicationService, IApplicationLifetimeAware
}
}
else {
- name = _windowName;
+ name = _mainViewName;
}
- Window mainWindow = null;
+ View mainView = null;
if (String.IsNullOrEmpty(name) == false) {
try {
- Type windowType = TypeTypeConverter.ParseTypeName(Application.Current, name);
- if (windowType == null) {
- throw new InvalidOperationException("The window named '" + name + "' could not be found.");
+ Type mainViewType = TypeTypeConverter.ParseTypeName(Application.Current, name);
+ if (mainViewType == null) {
+ throw new InvalidOperationException("The view named '" + name + "' could not be found.");
}
- if (typeof(UIElement).IsAssignableFrom(windowType) == false) {
- throw new InvalidOperationException("The window named '" + name + "' does not derive from UIElement.");
+ if (typeof(UIElement).IsAssignableFrom(mainViewType) == false) {
+ throw new InvalidOperationException("The view named '" + name + "' does not derive from UIElement.");
}
- UIElement uiElement = (UIElement)Activator.CreateInstance(windowType);
- mainWindow = uiElement as Window;
+ UIElement uiElement = (UIElement)Activator.CreateInstance(mainViewType);
+ mainView = uiElement as View;
- if (mainWindow == null) {
- mainWindow = new Window(uiElement);
+ if (mainView == null) {
+ mainView = new View(uiElement);
}
}
catch (Exception e) {
@@ -315,7 +280,7 @@ public class ApplicationContext : IApplicationService, IApplicationLifetimeAware
TextBlock errorText = new TextBlock();
errorText.Inlines.Add(new Run() {
- Text = "The window named '" + name + "' could not be instantiated.",
+ Text = "The view named '" + name + "' could not be instantiated.",
FontWeight = FontWeights.Bold,
Foreground = new SolidColorBrush(Colors.Red)
});
@@ -324,16 +289,51 @@ public class ApplicationContext : IApplicationService, IApplicationLifetimeAware
Text = e.Message
});
- mainWindow = new Window(errorText);
+ mainView = new View(errorText);
if (Debugger.IsAttached) {
throw;
}
}
}
- if (mainWindow != null) {
- Run(mainWindow);
+ if (mainView != null) {
+ Run(mainView);
+ }
+ }
+
+ private void InitializeTheme() {
+ if (String.IsNullOrEmpty(_themeName)) {
+ return;
}
+
+ string name = null;
+
+ if (_themeName.StartsWith("$")) {
+ string[] nameParts = _themeName.Split('|');
+ if ((nameParts.Length > 2) || String.IsNullOrEmpty(nameParts[0])) {
+ throw new InvalidOperationException("Invalid theme name. Either the name must be a simple name, or must be in the form $<ThemeInitParam>|<DefaultName>.");
+ }
+
+ if (nameParts.Length == 2) {
+ name = nameParts[1];
+ }
+ if (_startupArguments != null) {
+ string selectedName;
+ string argName = nameParts[0].Substring(1);
+ if (_startupArguments.TryGetValue(argName, out selectedName)) {
+ name = selectedName;
+ }
+ }
+ }
+ else {
+ name = _themeName;
+ }
+
+ if (String.IsNullOrEmpty(name)) {
+ return;
+ }
+
+ Theme.LoadTheme(Application.Current.Resources, name);
}
private void OnApplicationUnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e) {
@@ -394,28 +394,28 @@ public class ApplicationContext : IApplicationService, IApplicationLifetimeAware
/// </summary>
protected virtual void OnStarting() {
InitializeTheme();
- InitializeWindow();
+ InitializeMainView();
}
/// <summary>
- /// Runs the application using the specified main window as the top-most user interface element.
+ /// Runs the application using the specified main view as the top-most user interface element.
/// </summary>
- /// <param name="mainWindow">The main window to use to represent the application's user interface.</param>
- public void Run(Window mainWindow) {
- if (mainWindow == null) {
- throw new ArgumentNullException("mainWindow");
+ /// <param name="mainView">The main view to use to represent the application's user interface.</param>
+ public void Run(View mainView) {
+ if (mainView == null) {
+ throw new ArgumentNullException("mainView");
}
- if (_mainWindow != null) {
+ if (_mainView != null) {
throw new InvalidOperationException("Run can only be called once.");
}
- _mainWindow = mainWindow;
+ _mainView = mainView;
Screen screen = new Screen();
screen.Style = ScreenStyle;
Application.Current.RootVisual = screen;
- screen.Run(mainWindow);
+ screen.Run(mainView);
}
View
7 src/Client/Core/Core.csproj
@@ -199,6 +199,7 @@
<Compile Include="_System\ComponentModel\ScriptExpression.cs" />
<Compile Include="_System\ComponentModel\TaskViewModel.cs" />
<Compile Include="_System\Presentation\BindingShim.cs" />
+ <Compile Include="_System\Presentation\Controls\ViewModelAttribute.cs" />
<Compile Include="_System\Presentation\Controls\IAsyncControl.cs" />
<Compile Include="_System\Presentation\Controls\NavigatedEventArgs.cs" />
<Compile Include="_System\Presentation\Controls\NavigatingEventArgs.cs" />
@@ -209,7 +210,6 @@
<Compile Include="UserInterface\Glitz\BounceInterpolation.cs" />
<Compile Include="UserInterface\Glitz\ElasticInterpolation.cs" />
<Compile Include="UserInterface\Glitz\LinearInterpolation.cs" />
- <Compile Include="UserInterface\ViewUserControl.cs" />
<Compile Include="UserInterface\DetailView.cs">
<SubType>Code</SubType>
</Compile>
@@ -351,7 +351,7 @@
<Compile Include="UserInterface\Watermark.cs">
<SubType>Code</SubType>
</Compile>
- <Compile Include="UserInterface\Window.cs">
+ <Compile Include="UserInterface\View.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="UserInterface\XBorder.cs">
@@ -403,9 +403,6 @@
<Compile Include="_System\Presentation\Controls\IAdornableControl.cs">
<SubType>Code</SubType>
</Compile>
- <Compile Include="_System\Presentation\Controls\View.cs">
- <SubType>Code</SubType>
- </Compile>
<Compile Include="_System\Presentation\Data\DataboundControl.cs">
<SubType>Code</SubType>
</Compile>
View
2  src/Client/Core/Data/ObjectDataSource.cs
@@ -66,7 +66,7 @@ public class ObjectDataSource : DataSource {
return null;
}
- object model = View.GetModel(this);
+ object model = ViewModelAttribute.GetCurrentViewModel(this);
if (model == null) {
return null;
}
View
2  src/Client/Core/Themes/generic.xaml
@@ -56,7 +56,7 @@
<Setter.Value>
<ControlTemplate TargetType="fxui:Screen">
<Grid x:Name="RootElement">
- <ContentPresenter x:Name="WindowPresenter" />
+ <ContentPresenter x:Name="ViewPresenter" />
</Grid>
</ControlTemplate>
</Setter.Value>
View
2  src/Client/Core/UserInterface/Actions/InvokeMemberAction.cs
@@ -52,7 +52,7 @@ public abstract class InvokeMemberAction : TriggerAction<FrameworkElement> {
target = AssociatedObject;
}
else if (String.CompareOrdinal(_targetName, "$model") == 0) {
- target = View.GetModel(AssociatedObject);
+ target = ViewModelAttribute.GetCurrentViewModel(AssociatedObject);
}
else {
target = AssociatedObject.FindNameRecursive(_targetName);
View
10 src/Client/Core/UserInterface/Actions/ShowForm.cs
@@ -109,11 +109,9 @@ public sealed class ShowForm : TriggerAction<FrameworkElement>, IScriptExpressio
}
}
- if (formModel == null) {
- form = (Form)Activator.CreateInstance(formType);
- }
- else {
- form = (Form)Activator.CreateInstance(formType, formModel);
+ form = (Form)Activator.CreateInstance(formType);
+ if (formModel != null) {
+ View.SetViewModel(form, formModel);
}
form.Show();
@@ -127,7 +125,7 @@ public sealed class ShowForm : TriggerAction<FrameworkElement>, IScriptExpressio
return AssociatedObject.DataContext;
}
else if (name == "$model") {
- return View.GetModel(AssociatedObject);
+ return ViewModelAttribute.GetCurrentViewModel(AssociatedObject);
}
else if (name == "$element") {
return AssociatedObject;
View
2  src/Client/Core/UserInterface/EventTriggerBase.cs
@@ -59,7 +59,7 @@ public abstract class EventTriggerBase<T> : Trigger<T> where T : DependencyObjec
FrameworkElement fe = AssociatedObject as FrameworkElement;
if (fe != null) {
if (String.Compare(_sourceName, "$model", StringComparison.Ordinal) == 0) {
- return View.GetModel(fe);
+ return ViewModelAttribute.GetCurrentViewModel(fe);
}
if (String.Compare(_sourceName, "$dataContext", StringComparison.Ordinal) == 0) {
return fe.DataContext;
View
36 src/Client/Core/UserInterface/Form.cs
@@ -45,27 +45,6 @@ public class Form : View {
private DelegateCommand _okCommand;
/// <summary>
- /// Initializes an instance of a Form.
- /// </summary>
- public Form() :
- this(null) {
- }
-
- /// <summary>
- /// Initializes an instance of a Form with an associated view model.
- /// The view model is set as the DataContext of the Form.
- /// </summary>
- /// <param name="viewModel">The associated view model object.</param>
- public Form(object viewModel)
- : base(viewModel) {
- _cancelCommand = new DelegateCommand(OnCancelCommand, /* canExecute */ true);
- _okCommand = new DelegateCommand(OnOKCommand, /* canExecute */ true);
-
- Resources.Add("CancelCommand", _cancelCommand);
- Resources.Add("OKCommand", _okCommand);
- }
-
- /// <summary>
/// Gets or sets the effect to be played when the form is closing.
/// </summary>
public AnimationEffect CloseEffect {
@@ -167,7 +146,7 @@ public Form(object viewModel)
}
private void OnCancelCommand() {
- TaskViewModel model = View.GetModel(this) as TaskViewModel;
+ TaskViewModel model = View.GetViewModel(this) as TaskViewModel;
if (model != null) {
model.Cancel(delegate() {
Close(FormResult.Cancel);
@@ -182,8 +161,19 @@ public Form(object viewModel)
CloseCore();
}
+ /// <internalonly />
+ protected override void OnLoaded() {
+ base.OnLoaded();
+
+ _cancelCommand = new DelegateCommand(OnCancelCommand, /* canExecute */ true);
+ _okCommand = new DelegateCommand(OnOKCommand, /* canExecute */ true);
+
+ Resources.Add("CancelCommand", _cancelCommand);
+ Resources.Add("OKCommand", _okCommand);
+ }
+
private void OnOKCommand() {
- TaskViewModel model = View.GetModel(this) as TaskViewModel;
+ TaskViewModel model = View.GetViewModel(this) as TaskViewModel;
if (model != null) {
model.Commit(delegate() {
Close(FormResult.OK);
View
33 src/Client/Core/UserInterface/Interaction.cs
@@ -10,6 +10,7 @@
using System;
using System.Windows;
+using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Interactivity;
@@ -48,6 +49,13 @@ public static class Interaction {
DependencyProperty.RegisterAttached("Triggers", typeof(TriggerCollection), typeof(Interaction), null);
/// <summary>
+ /// Represents the VisualState attached property.
+ /// </summary>
+ public static readonly DependencyProperty VisualStateProperty =
+ DependencyProperty.RegisterAttached("VisualState", typeof(string), typeof(Interaction),
+ new PropertyMetadata(OnVisualStateChanged));
+
+ /// <summary>
/// Gets the action associated with the specified Button.
/// </summary>
/// <param name="button">The Button to lookup.</param>
@@ -116,6 +124,22 @@ public static class Interaction {
}
/// <summary>
+ /// Gets the visual state associated with the specified control.
+ /// </summary>
+ /// <param name="control">The control to lookup.</param>
+ /// <returns>The current visual state as it was last set.</returns>
+ public static string GetVisualState(Control control) {
+ return (string)control.GetValue(VisualStateProperty);
+ }
+
+ private static void OnVisualStateChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) {
+ string newState = (string)e.NewValue;
+ if (String.IsNullOrEmpty(newState) == false) {
+ VisualStateManager.GoToState((Control)o, newState, /* useTransitions */ true);
+ }
+ }
+
+ /// <summary>
/// Sets the action associated with the specified Button.
/// </summary>
/// <param name="button">The Button to associate the action with.</param>
@@ -183,5 +207,14 @@ public static class Interaction {
public static void SetTriggers(DependencyObject o, TriggerCollection triggers) {
o.SetValue(TriggersProperty, triggers);
}
+
+ /// <summary>
+ /// Sets the current visual state of the specified control.
+ /// </summary>
+ /// <param name="control">The control to set.</param>
+ /// <param name="state">The name of the state that the control should be in.</param>
+ public static void SetVisualState(Control control, string state) {
+ control.SetValue(VisualStateProperty, state);
+ }
}
}
View
2  src/Client/Core/UserInterface/ModelEventTrigger.cs
@@ -24,7 +24,7 @@ public sealed class ModelEventTrigger : EventTrigger {
protected override object GetSource() {
FrameworkElement fe = AssociatedObject as FrameworkElement;
if (fe != null) {
- return View.GetModel(fe);
+ return ViewModelAttribute.GetCurrentViewModel(fe);
}
return null;
}
View
16 src/Client/Core/UserInterface/Navigation/ErrorPage.cs
@@ -28,22 +28,6 @@ public class ErrorPage : Page {
private Exception _error;
/// <summary>
- /// Initializes an instance of a ErrorPage.
- /// </summary>
- public ErrorPage()
- : this(null) {
- }
-
- /// <summary>
- /// Initializes an instance of a Page with an associated view model.
- /// The view model is set as the DataContext of the Form.
- /// </summary>
- /// <param name="viewModel">The associated view model object.</param>
- public ErrorPage(object viewModel)
- : base(viewModel) {
- }
-
- /// <summary>
/// Gets the error associated with this ErrorPage instance.
/// </summary>
protected internal Exception Error {
View
27 src/Client/Core/UserInterface/Navigation/MvcPageLoader.cs
@@ -12,9 +12,7 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Navigation;
-using System.Reflection;
using System.Text;
-using System.Threading;
using System.Windows;
namespace SilverlightFX.UserInterface.Navigation {
@@ -158,30 +156,7 @@ public class MvcPageLoader : PageLoader {
if ((viewType != null) && typeof(Page).IsAssignableFrom(viewType)) {
page = (Page)Activator.CreateInstance(viewType);
- if (viewData != null) {
- object viewModel = page.Model;
- if (viewModel != null) {
- ISupportInitialize batchInitialize = viewModel as ISupportInitialize;
- if (batchInitialize != null) {
- batchInitialize.BeginInit();
- }
-
- Type viewModelType = viewModel.GetType();
- BindingFlags bindingFlags = BindingFlags.Public | BindingFlags.Instance |
- BindingFlags.FlattenHierarchy;
-
- foreach (KeyValuePair<string, object> viewDataItem in viewData) {
- PropertyInfo pi = viewModelType.GetProperty(viewDataItem.Key, bindingFlags);
- if ((pi != null) && pi.CanWrite) {
- pi.SetValue(viewModel, viewDataItem.Value, null);
- }
- }
-
- if (batchInitialize != null) {
- batchInitialize.EndInit();
- }
- }
- }
+ page.InitializeViewData(viewData);
if ((page is ErrorPage) && (errorResult != null)) {
((ErrorPage)page).Error = errorResult.Error;
View
16 src/Client/Core/UserInterface/Navigation/Page.cs
@@ -41,22 +41,6 @@ public class Page : View {
private EventHandler<PageStateEventArgs> _stateChangedHandler;
/// <summary>
- /// Initializes an instance of a Page.
- /// </summary>
- public Page()
- : this(null) {
- }
-
- /// <summary>
- /// Initializes an instance of a Page with an associated view model.
- /// The view model is set as the DataContext of the Form.
- /// </summary>
- /// <param name="viewModel">The associated view model object.</param>
- public Page(object viewModel)
- : base(viewModel) {
- }
-
- /// <summary>
/// Gets or sets the how the page should be cached or preserved when it
/// is no longer the active page the PageFrame it is hosted in.
/// True implies it must be preserved. False implies it should not be
View
42 src/Client/Core/UserInterface/Screen.cs
@@ -17,14 +17,14 @@
namespace SilverlightFX.UserInterface {
- // TODO: Add visual states for empty and for main window
- // TODO: Add effect properties for showing/hiding forms and main window
+ // TODO: Add visual states for empty and for main view
+ // TODO: Add effect properties for showing/hiding forms and main view
/// <summary>
/// Represents the root visual of an application.
/// </summary>
[TemplatePart(Name = "RootElement", Type = typeof(Grid))]
- [TemplatePart(Name = "WindowPresenter", Type = typeof(ContentPresenter))]
+ [TemplatePart(Name = "ViewPresenter", Type = typeof(ContentPresenter))]
public sealed class Screen : ContentControl {
/// <summary>
@@ -33,10 +33,10 @@ public sealed class Screen : ContentControl {
public static readonly DependencyProperty FormBackgroundProperty =
DependencyProperty.Register("FormBackground", typeof(Brush), typeof(Screen), null);
- private ContentPresenter _windowPresenter;
+ private ContentPresenter _viewPresenter;
private Grid _rootElement;
- private Window _mainWindow;
+ private View _mainView;
private Form _currentForm;
/// <summary>
@@ -62,8 +62,8 @@ public sealed class Screen : ContentControl {
internal void Close(Form form, Form previousForm) {
_currentForm = previousForm;
if (_currentForm == null) {
- _mainWindow.IsEnabled = true;
- _mainWindow.Focus();
+ _mainView.IsEnabled = true;
+ _mainView.Focus();
}
}
@@ -72,24 +72,24 @@ public sealed class Screen : ContentControl {
base.OnApplyTemplate();
_rootElement = GetTemplateChild("RootElement") as Grid;
- _windowPresenter = GetTemplateChild("WindowPresenter") as ContentPresenter;
+ _viewPresenter = GetTemplateChild("ViewPresenter") as ContentPresenter;
- if (_mainWindow != null) {
- _windowPresenter.Content = _mainWindow;
+ if (_mainView != null) {
+ _viewPresenter.Content = _mainView;
}
}
- internal void Run(Window mainWindow) {
- if (_mainWindow != null) {
+ internal void Run(View mainView) {
+ if (_mainView != null) {
throw new InvalidOperationException("The screen already contains content.");
}
- _mainWindow = mainWindow;
+ _mainView = mainView;
- if (_windowPresenter == null) {
+ if (_viewPresenter == null) {
ApplyTemplate();
}
else {
- _windowPresenter.Content = _mainWindow;
+ _viewPresenter.Content = _mainView;
}
}
@@ -105,21 +105,21 @@ public sealed class Screen : ContentControl {
throw new ArgumentNullException("screenContent");
}
- Window window = screenContent as Window;
- if (window == null) {
- window = new Window(screenContent);
+ View view = screenContent as View;
+ if (view == null) {
+ view = new View(screenContent);
}
- Run(window);
+ Run(view);
}
internal void Show(Form form) {
- if (_mainWindow == null) {
+ if (_mainView == null) {
return;
}
if (_currentForm == null) {
- _mainWindow.IsEnabled = false;
+ _mainView.IsEnabled = false;
}
Grid overlayElement = null;
View
118 src/Client/Core/UserInterface/View.cs
@@ -0,0 +1,118 @@
+// View.cs
+// Copyright (c) Nikhil Kothari, 2008. All Rights Reserved.
+// http://www.nikhilk.net
+//
+// Silverlight.FX is an application framework for building RIAs with Silverlight.
+// This project is licensed under the BSD license. See the accompanying License.txt
+// file for more information.
+// For updated project information please visit http://projects.nikhilk.net/SilverlightFX.
+//
+
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Reflection;
+using System.Windows;
+using System.Windows.Controls;
+
+namespace SilverlightFX.UserInterface {
+
+ /// <summary>
+ /// Represents the top-most view in an application.
+ /// </summary>
+ public class View : UserControl {
+
+ /// <summary>
+ /// Represents the Model attached property.
+ /// </summary>
+ public static readonly DependencyProperty ModelProperty =
+ DependencyProperty.RegisterAttached("Model", typeof(object), typeof(View),
+ new PropertyMetadata(OnModelPropertyChanged));
+
+ private IDictionary<string, object> _viewData;
+
+ /// <summary>
+ /// Initializes an instance of a View.
+ /// </summary>
+ public View() {
+ this.Loaded += OnLoaded;
+ }
+
+ internal View(UIElement content)
+ : this() {
+ Content = content;
+ }
+
+ /// <summary>
+ /// Gets the view model instance attached to the specified control.
+ /// </summary>
+ /// <param name="userControl">The control to lookup.</param>
+ /// <returns>The view model if one is associated with the control; null otherwise.</returns>
+ public static object GetViewModel(UserControl userControl) {
+ return userControl.GetValue(ModelProperty);
+ }
+
+ /// <summary>
+ /// Initializes the view with any view data. The View data is used to initialize
+ /// the associated view model.
+ /// </summary>
+ /// <param name="viewData"></param>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void InitializeViewData(IDictionary<string, object> viewData) {
+ _viewData = viewData;
+ }
+
+ /// <summary>
+ /// Performs initialization in response to the Loaded event.
+ /// </summary>
+ protected virtual void OnLoaded() {
+ object viewModel = View.GetViewModel(this);
+ if (viewModel == null) {
+ viewModel = ViewModelAttribute.CreateViewModel(this);
+ if (viewModel != null) {
+ View.SetViewModel(this, viewModel);
+ }
+ }
+
+ if ((viewModel != null) && (_viewData != null)) {
+ ISupportInitialize batchInitialize = viewModel as ISupportInitialize;
+ if (batchInitialize != null) {
+ batchInitialize.BeginInit();
+ }
+
+ Type viewModelType = viewModel.GetType();
+ BindingFlags bindingFlags = BindingFlags.Public | BindingFlags.Instance |
+ BindingFlags.FlattenHierarchy;
+
+ foreach (KeyValuePair<string, object> viewDataItem in _viewData) {
+ PropertyInfo pi = viewModelType.GetProperty(viewDataItem.Key, bindingFlags);
+ if ((pi != null) && pi.CanWrite) {
+ pi.SetValue(viewModel, viewDataItem.Value, null);
+ }
+ }
+
+ if (batchInitialize != null) {
+ batchInitialize.EndInit();
+ }
+ }
+ }
+
+ private void OnLoaded(object sender, RoutedEventArgs e) {
+ OnLoaded();
+ }
+
+ private static void OnModelPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) {
+ ViewModelAttribute.SetViewModel((UserControl)d, e.NewValue);
+ }
+
+ /// <summary>
+ /// Sets the view model instance attached to the specified control.
+ /// The view model is also used as the DataContext assigned to the control.
+ /// </summary>
+ /// <param name="userControl">The control to associated the view model with.</param>
+ /// <param name="value">The view model instance.</param>
+ public static void SetViewModel(UserControl userControl, object value) {
+ userControl.SetValue(ModelProperty, value);
+ }
+ }
+}
View
38 src/Client/Core/UserInterface/ViewUserControl.cs
@@ -1,38 +0,0 @@
-// ViewUserControl.cs
-// Copyright (c) Nikhil Kothari, 2008. All Rights Reserved.
-// http://www.nikhilk.net
-//
-// Silverlight.FX is an application framework for building RIAs with Silverlight.
-// This project is licensed under the BSD license. See the accompanying License.txt
-// file for more information.
-// For updated project information please visit http://projects.nikhilk.net/SilverlightFX.
-//
-
-using System;
-using System.ComponentModel;
-using System.Windows;
-using System.Windows.Controls;
-
-namespace SilverlightFX.UserInterface {
-
- /// <summary>
- /// Represents a user control within the application's user interface.
- /// </summary>
- public class ViewUserControl : View {
-
- /// <summary>
- /// Initializes an instance of a ViewUserControl.
- /// </summary>
- public ViewUserControl() {
- }
-
- /// <summary>
- /// Initializes an instance of a ViewUserControl with an associated view model.
- /// The view model is set as the DataContext of the Form.
- /// </summary>
- /// <param name="viewModel">The associated view model object.</param>
- public ViewUserControl(object viewModel)
- : base(viewModel) {
- }
- }
-}
View
43 src/Client/Core/UserInterface/Window.cs
@@ -1,43 +0,0 @@
-// Window.cs
-// Copyright (c) Nikhil Kothari, 2008. All Rights Reserved.
-// http://www.nikhilk.net
-//
-// Silverlight.FX is an application framework for building RIAs with Silverlight.
-// This project is licensed under the BSD license. See the accompanying License.txt
-// file for more information.
-// For updated project information please visit http://projects.nikhilk.net/SilverlightFX.
-//
-
-using System;
-using System.ComponentModel;
-using System.Windows;
-using System.Windows.Controls;
-
-namespace SilverlightFX.UserInterface {
-
- /// <summary>
- /// Represents the top-most window in an application.
- /// </summary>
- public class Window : View {
-
- /// <summary>
- /// Initializes an instance of a Window.
- /// </summary>
- public Window() :
- this(null) {
- }
-
- /// <summary>
- /// Initializes an instance of a Window with an associated view model.
- /// The view model is set as the DataContext of the Form.
- /// </summary>
- /// <param name="viewModel">The associated view model object.</param>
- public Window(object viewModel)
- : base(viewModel) {
- }
-
- internal Window(UIElement content) {
- Content = content;
- }
- }
-}
View
4 src/Client/Core/_System/ComponentModel/TypeTypeConverter.cs
@@ -32,6 +32,10 @@ public sealed class TypeTypeConverter : TypeConverter {
/// <internalonly />
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) {
if (value is string) {
+ if (DesignerProperties.IsInDesignTool) {