Skip to content

Commit 2443d78

Browse files
JMJM
authored andcommitted
Refactored much of the sample app logic into a SampleViewModel class.
Added support to the sample app for displaying a summary of the currently selected data source including RecordCount. Removed some extraneous options from the sample app.
1 parent 2a0bbe9 commit 2443d78

4 files changed

Lines changed: 320 additions & 309 deletions

File tree

DataPresenter.DataSources.OData/DataPresenter.DataSources.OData.SampleApp/DataPresenter.DataSources.OData.SampleApp.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
<Generator>MSBuild:Compile</Generator>
8080
<SubType>Designer</SubType>
8181
</ApplicationDefinition>
82+
<Compile Include="SampleViewModel.cs" />
8283
<Page Include="MainWindow.xaml">
8384
<Generator>MSBuild:Compile</Generator>
8485
<SubType>Designer</SubType>

DataPresenter.DataSources.OData/DataPresenter.DataSources.OData.SampleApp/MainWindow.xaml

Lines changed: 129 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -12,81 +12,96 @@
1212
xmlns:sys="clr-namespace:System;assembly=mscorlib"
1313
mc:Ignorable="d"
1414
Title="MainWindow" Height="800" Width="1100">
15+
<Window.DataContext>
16+
<local:SampleViewModel/>
17+
</Window.DataContext>
18+
1519
<Window.Resources>
1620
<BooleanToVisibilityConverter x:Key="boolToVisibility"/>
21+
22+
<Style x:Key="HeaderText1" TargetType="TextBlock">
23+
<Setter Property="FontWeight" Value="Bold"/>
24+
<Setter Property="Foreground" Value="#FF0052A6"/>
25+
<Setter Property="Margin" Value="0,3"/>
26+
<Setter Property="FontSize" Value="18"/>
27+
</Style>
28+
29+
<Style x:Key="HeaderText2" TargetType="TextBlock">
30+
<Setter Property="FontWeight" Value="Bold"/>
31+
<Setter Property="Foreground" Value="#FF0072C6"/>
32+
<Setter Property="Margin" Value="0,3"/>
33+
<Setter Property="FontSize" Value="14"/>
34+
</Style>
35+
36+
<Style x:Key="LabelText" TargetType="TextBlock">
37+
<Setter Property="FontWeight" Value="Bold"/>
38+
<Setter Property="Margin" Value="0,3"/>
39+
<Setter Property="VerticalAlignment" Value="Center"/>
40+
</Style>
41+
42+
<Style x:Key="ColorPicker" TargetType="igControls:XamColorPicker">
43+
<Setter Property="Margin" Value="0,3"/>
44+
</Style>
45+
46+
<Style x:Key="TextBoxText" TargetType="TextBox">
47+
<Setter Property="FontWeight" Value="Regular"/>
48+
<Setter Property="Foreground" Value="Black"/>
49+
<Setter Property="FontSize" Value="14"/>
50+
<Setter Property="Margin" Value="0,3"/>
51+
</Style>
52+
53+
<Style x:Key="NumericEditorText" TargetType="igEditors:XamNumericEditor">
54+
<Setter Property="FontWeight" Value="Regular"/>
55+
<Setter Property="Foreground" Value="Black"/>
56+
<Setter Property="FontSize" Value="14"/>
57+
<Setter Property="Margin" Value="0,2"/>
58+
<Setter Property="Width" Value="100"/>
59+
<Setter Property="HorizontalAlignment" Value="Left"/>
60+
<Setter Property="SpinButtonDisplayMode" Value="Always"/>
61+
<Setter Property="SpinIncrement" Value="10"/>
62+
<Setter Property="Mask" Value="9999"/>
63+
</Style>
64+
65+
<Style x:Key="ComboBoxText" TargetType="ComboBox">
66+
<Setter Property="FontWeight" Value="Regular"/>
67+
<Setter Property="Foreground" Value="Black"/>
68+
<Setter Property="FontSize" Value="14"/>
69+
<Setter Property="Margin" Value="0,2"/>
70+
</Style>
71+
72+
<Style x:Key="CheckBoxText" TargetType="CheckBox">
73+
<Setter Property="FontWeight" Value="Regular"/>
74+
<Setter Property="Foreground" Value="Black"/>
75+
<Setter Property="FontSize" Value="14"/>
76+
<Setter Property="Margin" Value="0,2"/>
77+
<Setter Property="VerticalAlignment" Value="Center"/>
78+
</Style>
1779
</Window.Resources>
1880

1981
<Grid>
82+
<Grid.RowDefinitions>
83+
<RowDefinition Height="Auto"/>
84+
<RowDefinition Height="*"/>
85+
</Grid.RowDefinitions>
86+
2087
<Grid.ColumnDefinitions>
2188
<ColumnDefinition Width="5*"/>
2289
<ColumnDefinition Width="Auto"/>
2390
<ColumnDefinition Width="9*"/>
2491
</Grid.ColumnDefinitions>
2592

26-
<StackPanel Grid.Column="0" Margin="6">
93+
<StackPanel Grid.RowSpan="2" Grid.Column="0" Margin="6">
2794
<StackPanel>
28-
<StackPanel.Resources>
29-
<Style x:Key="HeaderText1" TargetType="TextBlock">
30-
<Setter Property="FontWeight" Value="Bold"/>
31-
<Setter Property="Foreground" Value="#FF0052A6"/>
32-
<Setter Property="Margin" Value="0,3"/>
33-
<Setter Property="FontSize" Value="18"/>
34-
</Style>
35-
36-
<Style x:Key="HeaderText2" TargetType="TextBlock">
37-
<Setter Property="FontWeight" Value="Bold"/>
38-
<Setter Property="Foreground" Value="#FF0072C6"/>
39-
<Setter Property="Margin" Value="0,3"/>
40-
<Setter Property="FontSize" Value="14"/>
41-
</Style>
42-
43-
<Style x:Key="LabelText" TargetType="TextBlock">
44-
<Setter Property="FontWeight" Value="Bold"/>
45-
<Setter Property="Margin" Value="0,3"/>
46-
<Setter Property="VerticalAlignment" Value="Center"/>
47-
</Style>
48-
49-
<Style x:Key="ColorPicker" TargetType="igControls:XamColorPicker">
50-
<Setter Property="Margin" Value="0,3"/>
51-
</Style>
52-
53-
<Style x:Key="TextBoxText" TargetType="TextBox">
54-
<Setter Property="FontWeight" Value="Regular"/>
55-
<Setter Property="Foreground" Value="Black"/>
56-
<Setter Property="FontSize" Value="14"/>
57-
<Setter Property="Margin" Value="0,3"/>
58-
</Style>
59-
60-
<Style x:Key="NumericEditorText" TargetType="igEditors:XamNumericEditor">
61-
<Setter Property="FontWeight" Value="Regular"/>
62-
<Setter Property="Foreground" Value="Black"/>
63-
<Setter Property="FontSize" Value="14"/>
64-
<Setter Property="Margin" Value="0,2"/>
65-
</Style>
66-
67-
<Style x:Key="ComboBoxText" TargetType="ComboBox">
68-
<Setter Property="FontWeight" Value="Regular"/>
69-
<Setter Property="Foreground" Value="Black"/>
70-
<Setter Property="FontSize" Value="14"/>
71-
<Setter Property="Margin" Value="0,2"/>
72-
</Style>
73-
74-
<Style x:Key="CheckBoxText" TargetType="CheckBox">
75-
<Setter Property="FontWeight" Value="Regular"/>
76-
<Setter Property="Foreground" Value="Black"/>
77-
<Setter Property="FontSize" Value="14"/>
78-
<Setter Property="Margin" Value="0,2"/>
79-
<Setter Property="VerticalAlignment" Value="Center"/>
80-
</Style>
81-
</StackPanel.Resources>
82-
83-
<!-- Dropdown list of publicly accessible ODATA SERVICES-->
95+
<!-- A dropdown list of publicly accessible ODATA SERVICES-->
8496
<TextBlock Text="ODATA SERVICES" Style="{StaticResource HeaderText1}"/>
85-
<ComboBox x:Name="cboOdataSources" SelectionChanged="cboOdataSources_SelectionChanged" Style="{StaticResource ComboBoxText}">
97+
<ComboBox x:Name="cboOdataSources"
98+
SelectedIndex="0"
99+
SelectedValue="{Binding CurrentDataSourceConfigurationInfo}"
100+
Style="{StaticResource ComboBoxText}">
86101
<local:DataSourceConfigurationInfo BaseUri="http://data.scottsdaleaz.gov/Planning/BuildingPermits.svc" EntitySet="BuildingPermits" Description="Scottsdale Building Permits">
87-
<!-- Limit the amount of data fetched from this OData service by setting the FieldsRequested property. Refer to
88-
the cboOdataSources_SelectionChanged event handler code in MainWindow.xaml.cs to see how we apply these settings when
89-
we create a new ODataDataSource instance. -->
102+
<!-- An example of how to improve data source responsiveness by limiting the amount of data fetched from this OData
103+
service. We do this by setting the FieldsRequested property to a subset of all fields defined in the backend schema.
104+
Note that this requires knowledge of the field names defined in the backend schema. -->
90105
<local:DataSourceConfigurationInfo.FieldsRequested>
91106
<x:Array Type="sys:String">
92107
<sys:String>PermitNumber</sys:String>
@@ -109,7 +124,6 @@
109124
<local:DataSourceConfigurationInfo BaseUri="http://services.odata.org/AdventureWorksV3/AdventureWorks.svc" EntitySet="WorkOrderRouting" Description="AdventureWorks Workorder Routing"/>
110125
<local:DataSourceConfigurationInfo BaseUri="http://packages.nuget.org/v1/FeedService.svc" EntitySet="Packages" Description="NuGet Packages"/>
111126
</ComboBox>
112-
<CheckBox x:Name="chkNullOutDatasource" IsChecked="True" Style="{StaticResource CheckBoxText}">Null out datasource before setting new</CheckBox>
113127

114128
<!-- Separator -->
115129
<Rectangle Height="1" HorizontalAlignment="Stretch" Fill="Gray" Margin="5,20,5,0"/>
@@ -118,9 +132,9 @@
118132
<Rectangle Width="1" Height="20" Fill="Transparent"/>
119133
<TextBlock Text="DATASOURCE SETTINGS" Style="{StaticResource HeaderText1}"/>
120134

121-
<!-- Desired Page Size -->
135+
<!-- Page Size Requested -->
122136
<TextBlock Text="PAGE SIZE REQUESTED" Style="{StaticResource HeaderText2}"/>
123-
<igEditors:XamNumericEditor x:Name="numPageSizeRequested" Width="100" HorizontalAlignment="Left" Mask="9999" EditModeEnded="numPageSizeRequested_EditModeEnded" SpinButtonDisplayMode="Always" SpinIncrement="10" Style="{StaticResource NumericEditorText}">
137+
<igEditors:XamNumericEditor x:Name="numPageSizeRequested" Value="{Binding PageSizeRequested}" ValueType="{x:Type sys:Int32}" Style="{StaticResource NumericEditorText}">
124138
<igEditors:XamNumericEditor.ValueConstraint>
125139
<igEditors:ValueConstraint MinInclusive="5" MaxInclusive="1000"/>
126140
</igEditors:XamNumericEditor.ValueConstraint>
@@ -129,7 +143,7 @@
129143
<!-- Maximum number of cached pages -->
130144
<Rectangle Width="1" Height="20" Fill="Transparent"/>
131145
<TextBlock Text="MAX # CACHED PAGES" Style="{StaticResource HeaderText2}"/>
132-
<igEditors:XamNumericEditor x:Name="numMaxCachedPages" Width="100" HorizontalAlignment="Left" Mask="9999" EditModeEnded="numMaxCachedPages_EditModeEnded" SpinButtonDisplayMode="Always" SpinIncrement="10" Style="{StaticResource NumericEditorText}">
146+
<igEditors:XamNumericEditor x:Name="numMaxCachedPages" Value="{Binding MaxCachedPages}" ValueType="{x:Type sys:Int32}" Style="{StaticResource NumericEditorText}">
133147
<igEditors:XamNumericEditor.ValueConstraint>
134148
<igEditors:ValueConstraint MinInclusive="5" MaxInclusive="1000"/>
135149
</igEditors:XamNumericEditor.ValueConstraint>
@@ -172,7 +186,7 @@
172186
</Grid.RowDefinitions>
173187

174188
<TextBlock Grid.Row="0" Grid.Column="0" Text="RECORD FILTER LOGICAL OPERATOR" Style="{StaticResource LabelText}"/>
175-
<ComboBox x:Name="cboRecordFilterLogicalOperator" Grid.Row="0" Grid.Column="1" SelectionChanged="cboRecordFilterLogicalOperator_SelectionChanged" Margin="2" Style="{StaticResource ComboBoxText}">
189+
<ComboBox x:Name="cboRecordFilterLogicalOperator" Grid.Row="0" Grid.Column="1" SelectedIndex="0" SelectionChanged="cboRecordFilterLogicalOperator_SelectionChanged" Margin="2" Style="{StaticResource ComboBoxText}">
176190
<sys:String>And</sys:String>
177191
<sys:String>Or</sys:String>
178192
</ComboBox>
@@ -189,18 +203,9 @@
189203

190204
<Grid.RowDefinitions>
191205
<RowDefinition />
192-
<RowDefinition />
193206
</Grid.RowDefinitions>
194207

195-
<TextBlock Grid.Row="0" Grid.Column="0" Text="VIEW" Style="{StaticResource LabelText}"/>
196-
<ComboBox x:Name="cboDataPresenterView" Grid.Row="0" Grid.Column="1" SelectionChanged="cboDataPresenterView_SelectionChanged" Margin="2" Style="{StaticResource ComboBoxText}">
197-
<sys:String>GridView</sys:String>
198-
<sys:String>CardView</sys:String>
199-
<sys:String>CarouselView</sys:String>
200-
<sys:String>TreeView</sys:String>
201-
</ComboBox>
202-
203-
<TextBlock Grid.Row="1" Grid.Column="0" Text="THEME" Style="{StaticResource LabelText}"/>
208+
<TextBlock Grid.Row="0" Grid.Column="0" Text="THEME" Style="{StaticResource LabelText}"/>
204209
<ComboBox x:Name="cboThemes" Grid.Row="1" Grid.Column="1" SelectionChanged="cboThemes_SelectionChanged" Margin="2" Style="{StaticResource ComboBoxText}"/>
205210
</Grid>
206211

@@ -234,9 +239,52 @@
234239
</StackPanel>
235240
</StackPanel>
236241

237-
<GridSplitter Grid.Column="1" Width="7" Margin="2,0" Background="#FFDDDDDD" ResizeBehavior="PreviousAndNext"/>
242+
<GridSplitter Grid.Column="1" Grid.RowSpan="2" Width="7" Margin="2,0" Background="#FFBBBBBB" ResizeBehavior="PreviousAndNext"/>
243+
244+
<!-- Summary info for the currently selected OData DataSource -->
245+
<Grid Grid.Column="2" Margin="5,0,5,20">
246+
<Grid.RowDefinitions>
247+
<RowDefinition Height="Auto"/>
248+
<RowDefinition Height="Auto"/>
249+
</Grid.RowDefinitions>
250+
251+
<Grid.ColumnDefinitions>
252+
<ColumnDefinition Width="Auto"/>
253+
<ColumnDefinition Width="*"/>
254+
<ColumnDefinition Width="*"/>
255+
</Grid.ColumnDefinitions>
256+
257+
<Border Grid.Column="0" BorderThickness="0,0,1,1" BorderBrush="DarkGray">
258+
<TextBlock Text="DATA SOURCE URI" Style="{StaticResource HeaderText2}" Padding="3,0"/>
259+
</Border>
260+
<Border Grid.Column="1" BorderThickness="0,0,1,1" BorderBrush="DarkGray">
261+
<TextBlock Text="ENTITYSET" Style="{StaticResource HeaderText2}" Padding="3,0"/>
262+
</Border>
263+
<Border Grid.Column="2" BorderThickness="0,0,0,1" BorderBrush="DarkGray">
264+
<TextBlock Text="# RECORDS" Style="{StaticResource HeaderText2}" Padding="3,0"/>
265+
</Border>
266+
267+
<Border Grid.Row="1" Grid.Column="0" Padding="0,0,6,0" BorderThickness="0,0,1,0" BorderBrush="DarkGray">
268+
<TextBlock Grid.Row="1" Grid.Column="0" Text="{Binding ElementName=cboOdataSources, Path=(SelectedItem).BaseUri}" Padding="3,0"/>
269+
</Border>
270+
271+
<Border Grid.Row="1" Grid.Column="1" Padding="0,0,6,0" BorderThickness="0,0,1,0" BorderBrush="DarkGray">
272+
<TextBlock Text="{Binding ElementName=cboOdataSources, Path=(SelectedItem).EntitySet}" Padding="3,0"/>
273+
</Border>
274+
275+
<Border Grid.Row="1" Grid.Column="2" Padding="0,0,6,0">
276+
<TextBlock Text="{Binding Path=CurrentDataSource.RecordCount, StringFormat=N0}" Padding="3,0"/>
277+
</Border>
278+
</Grid>
238279

239-
<igDP:XamDataPresenter x:Name="dataPresenter1" Grid.Column="2" Theme="{Binding ElementName=cboThemes, Path=SelectedValue, Mode=OneWay}" Margin="5,0,0,0">
280+
<!-- XamDataPresenter -->
281+
<igDP:XamDataPresenter x:Name="dataPresenter1"
282+
Grid.Row="1"
283+
Grid.Column="2"
284+
DataSource="{Binding CurrentDataSource}"
285+
Theme="{Binding ElementName=cboThemes, Path=SelectedValue, Mode=OneWay}"
286+
Margin="5"
287+
GroupByAreaLocation="None">
240288
<igDP:XamDataPresenter.FieldLayoutSettings>
241289
<igDP:FieldLayoutSettings FilterEvaluationMode="UseCollectionView"/>
242290
</igDP:XamDataPresenter.FieldLayoutSettings>
@@ -246,7 +294,9 @@
246294
</igDP:XamDataPresenter.FieldSettings>
247295
</igDP:XamDataPresenter>
248296

249-
<igControls:XamBusyIndicator Grid.Column="2"
297+
<!-- XamBusyIndicator -->
298+
<igControls:XamBusyIndicator Grid.Row="1"
299+
Grid.Column="2"
250300
IsBusy="{Binding ElementName=dataPresenter1, Path=IsAsyncDataPending}"
251301
Visibility="{Binding ElementName=chkShowBusyIndicator, Path=IsChecked, Converter={StaticResource boolToVisibility}}"
252302
BusyContent="Fetching Data..."

0 commit comments

Comments
 (0)