Skip to content

Commit

Permalink
Introduced ObjectDataSource control - DataSource bound to ViewModel
Browse files Browse the repository at this point in the history
Added TwitFaves sample demonstrating ObjectDataSource and ActivityControl
  • Loading branch information
nikhilk committed Oct 8, 2009
1 parent 5f69725 commit 3dc77ed
Show file tree
Hide file tree
Showing 40 changed files with 2,690 additions and 134 deletions.
5 changes: 4 additions & 1 deletion History.txt
Expand Up @@ -3,7 +3,10 @@
- ComponentModel enhancements:
Tuple, ErrorEventArgs, Async
- Control additions:
LinkLabel, WrapPanel, ActivityControl
LinkLabel, WrapPanel, ActivityControl, ObjectDataSource
- Removed ElementProperty, replaced with BoundParameter
- Removed Parameter property on SetProperty, and replaced with ValueBinding
property


0.3.2 Release
Expand Down
35 changes: 35 additions & 0 deletions samples/Experiments/DataSourcePage.xaml
@@ -0,0 +1,35 @@
<fxui:ViewUserControl
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">
<Grid Background="White" Margin="20" HorizontalAlignment="Center">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="60" />
<ColumnDefinition Width="300" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>

<TextBlock Style="{StaticResource flatLabel}" Text="Search:" VerticalAlignment="Center" FontWeight="Bold" />
<TextBox x:Name="searchTextBox" Margin="2" Grid.Column="1" />

<Button x:Name="searchButton" Grid.Row="1" Grid.Column="1" Margin="2" Width="75" Height="23" HorizontalAlignment="Center"
Content="Search" />

<ListBox x:Name="searchResults" VerticalAlignment="Top" Grid.Row="2" Grid.ColumnSpan="2" Margin="2"
ItemsSource="{Binding ElementName=itemsDataSource, Path=Data}" />

<fxdata:ObjectDataSource x:Name="itemsDataSource" QueryName="GetItems" AutoLoadData="True">
<fxdata:ObjectDataSource.QueryParameters>
<fxdata:BoundParameter ParameterName="prefix" ValueBinding="{Binding ElementName=searchTextBox, Path=Text}" />
</fxdata:ObjectDataSource.QueryParameters>
</fxdata:ObjectDataSource>
</Grid>
</fxui:ViewUserControl>
50 changes: 50 additions & 0 deletions samples/Experiments/DataSourcePage.xaml.cs
@@ -0,0 +1,50 @@
// DataSourcePage.xaml.cs
//

using System;
using System.Windows;
using System.Windows.Controls;
using System.ComponentModel;
using System.Collections.Generic;
using System.Linq;
using SilverlightFX.UserInterface;

namespace Experiments {

public class DataItem {

public string Name { get; set; }

public int Value { get; set; }

public override string ToString() {
return Name + " (" + Value + ")";
}
}

public class DataViewModel : ViewModel {

private List<DataItem> Items = new List<DataItem>() {
new DataItem() { Name = "Foo" },
new DataItem() { Name = "FooBar" },
new DataItem() { Name = "Baz" },
new DataItem() { Name = "FooBarBaz" }
};

public IEnumerable<DataItem> GetItems(string prefix) {
List<DataItem> items = Items.Where(i => i.Name.StartsWith(prefix, StringComparison.OrdinalIgnoreCase)).ToList();
foreach (DataItem dataItem in items) {
dataItem.Value++;
}

return items;
}
}

public partial class DataSourcePage : ViewUserControl {

public DataSourcePage() {
InitializeComponent();
}
}
}
14 changes: 14 additions & 0 deletions samples/Experiments/Experiments.csproj
Expand Up @@ -73,6 +73,12 @@
<Compile Include="BouncePage.xaml.cs">
<DependentUpon>BouncePage.xaml</DependentUpon>
</Compile>
<Compile Include="ActivityPage.xaml.cs">
<DependentUpon>ActivityPage.xaml</DependentUpon>
</Compile>
<Compile Include="DataSourcePage.xaml.cs">
<DependentUpon>DataSourcePage.xaml</DependentUpon>
</Compile>
<Compile Include="NumberEditForm.xaml.cs">
<DependentUpon>NumberEditForm.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -158,6 +164,14 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="ActivityPage.xaml">
<Generator>MSBuild:MarkupCompilePass1</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="DataSourcePage.xaml">
<Generator>MSBuild:MarkupCompilePass1</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="NumberEditForm.xaml">
<Generator>MSBuild:MarkupCompilePass1</Generator>
<SubType>Designer</SubType>
Expand Down
4 changes: 1 addition & 3 deletions samples/Experiments/ViewModelPage.xaml
Expand Up @@ -16,9 +16,7 @@
Content="Initialize">
<fxui:Interaction.Triggers>
<fxui:ClickTrigger>
<fxactions:SetProperty PropertyName="Value">
<fxui:ElementProperty ElementName="valueTextBox" PropertyName="Text" />
</fxactions:SetProperty>
<fxactions:SetProperty PropertyName="Value" ValueBinding="{Binding ElementName=valueTextBox, Path=Text}" />
</fxui:ClickTrigger>
</fxui:Interaction.Triggers>
</fxui:XButton>
Expand Down
7 changes: 7 additions & 0 deletions samples/Samples.sln
Expand Up @@ -27,6 +27,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AmazonStore", "AmazonStore\
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "News", "News\News.csproj", "{750026A4-3EA6-4D5F-B6DB-EBECDD3A8D3A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TwitFaves", "TwitFaves\TwitFaves.csproj", "{DB259CE6-96A8-4F59-A0D5-A3F6815F4732}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -77,6 +79,10 @@ Global
{750026A4-3EA6-4D5F-B6DB-EBECDD3A8D3A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{750026A4-3EA6-4D5F-B6DB-EBECDD3A8D3A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{750026A4-3EA6-4D5F-B6DB-EBECDD3A8D3A}.Release|Any CPU.Build.0 = Release|Any CPU
{DB259CE6-96A8-4F59-A0D5-A3F6815F4732}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DB259CE6-96A8-4F59-A0D5-A3F6815F4732}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DB259CE6-96A8-4F59-A0D5-A3F6815F4732}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DB259CE6-96A8-4F59-A0D5-A3F6815F4732}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -92,5 +98,6 @@ Global
{6F2D06F0-B548-4D89-8628-A7EB3BE4A8BE} = {38EE0482-5653-49CE-9C94-EBF490218D23}
{A8C08DAF-477C-4CEB-9AA8-21C412A06452} = {38EE0482-5653-49CE-9C94-EBF490218D23}
{750026A4-3EA6-4D5F-B6DB-EBECDD3A8D3A} = {38EE0482-5653-49CE-9C94-EBF490218D23}
{DB259CE6-96A8-4F59-A0D5-A3F6815F4732} = {38EE0482-5653-49CE-9C94-EBF490218D23}
EndGlobalSection
EndGlobal
26 changes: 26 additions & 0 deletions samples/TwitFaves/App.xaml
@@ -0,0 +1,26 @@
<Application
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:fxapp="clr-namespace:SilverlightFX.Applications;assembly=SilverlightFX"
xmlns:fxdata="clr-namespace:SilverlightFX.Data;assembly=SilverlightFX"
xmlns:data="clr-namespace:TwitFaves.Data"
x:Class="TwitFaves.App">

<Application.ApplicationLifetimeObjects>
<fxapp:ApplicationContext x:Name="appContext" WindowName="TwitFaves.MainWindow">
<data:TwitterService />
</fxapp:ApplicationContext>
</Application.ApplicationLifetimeObjects>

<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Assets/Theme.xaml"/>
</ResourceDictionary.MergedDictionaries>

<fxdata:StringFormatter x:Key="stringFormatter" />
<fxdata:VisibilityConverter x:Key="visibilityConverter" />
<fxdata:DateFormatter x:Key="dateFormatter" />
</ResourceDictionary>
</Application.Resources>
</Application>
15 changes: 15 additions & 0 deletions samples/TwitFaves/App.xaml.cs
@@ -0,0 +1,15 @@
// App.xaml.cs
//

using System;
using System.Windows;

namespace TwitFaves {

public partial class App : Application {

public App() {
InitializeComponent();
}
}
}
Binary file added samples/TwitFaves/Assets/Bird.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added samples/TwitFaves/Assets/Clouds.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added samples/TwitFaves/Assets/Logo.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 3dc77ed

Please sign in to comment.