Permalink
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...
nikhilk committed Jan 2, 2010
1 parent df1ff9b commit 53b7284f49992e835df9ca44972ad37c15de1b23
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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

Large diffs are not rendered by default.

Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -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>
@@ -8,7 +8,7 @@
namespace AmazonSearch.Views {
- public class SearchViewModel : Model {
+ public class SearchViewModel : ViewModel {
private ICatalog _catalog;
@@ -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>
@@ -7,7 +7,7 @@
namespace AmazonSearch.Views {
- public partial class SearchView : Window {
+ public partial class SearchView : View {
public SearchView() {
InitializeComponent();
@@ -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>
@@ -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>
@@ -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();
@@ -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>
@@ -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();
}
}
@@ -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>
@@ -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>
@@ -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>
@@ -51,7 +51,7 @@ public class ActivityViewModel : ViewModel {
}
}
- public partial class ActivityPage : ViewUserControl {
+ public partial class ActivityPage : View {
public ActivityPage() {
InitializeComponent();
@@ -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>
@@ -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>
@@ -41,7 +41,8 @@ public class DataViewModel : ViewModel {
}
}
- public partial class DataSourcePage : ViewUserControl {
+ [ViewModel(typeof(DataViewModel))]
+ public partial class DataSourcePage : View {
public DataSourcePage() {
InitializeComponent();
@@ -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>
@@ -90,7 +90,8 @@ public class ListModel : Model {
}
}
- public partial class DetailViewPage : Window {
+ [ViewModel(typeof(ListModel))]
+ public partial class DetailViewPage : View {
public DetailViewPage() {
InitializeComponent();
@@ -35,8 +35,7 @@ public class NumberEditModel : TaskViewModel {
public partial class NumberEditForm : Form {
- public NumberEditForm(NumberEditModel model)
- : base(model) {
+ public NumberEditForm() {
InitializeComponent();
}
}
@@ -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>
@@ -32,7 +32,7 @@ public class ParentPageModel : ViewModel {
}
}
- public partial class ParentPage : ViewUserControl {
+ public partial class ParentPage : View {
public ParentPage() {
InitializeComponent();
@@ -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>
@@ -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>
@@ -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>
Oops, something went wrong.

0 comments on commit 53b7284

Please sign in to comment.