added samples
[windows-sources.git] / sdk / samples / WPFSamples / ExpenseIt / csharp / app.xaml
blob9dbf8ca5d305871573d53eddb1bcc435744b531a
1 <Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
2              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
3              StartupUri="HomePage.xaml"
4              x:Class="ExpenseIt.App"
5              xmlns:l="clr-namespace:Editing"
6              xmlns:MappingPIGen1="clr-namespace:ExpenseIt"
7              xmlns:localValidation="clr-namespace:ExpenseIt.Validation"
8              >
9   <Application.Resources>
10     <ExpenseReport x:Key="ExpenseData"
11                    xmlns="clr-namespace:ExpenseIt"
12                    Alias="Someone@example.com"
13                    EmployeeNumber="57304"
14                    CostCenter="4032">
15       <ExpenseReport.LineItems>
16         <LineItem Type="Meal"
17                   Description="Mexican Lunch"
18                   Cost="12" />
19         <LineItem Type="Meal"
20                   Description="Italian Dinner"
21                   Cost="45" />
22         <LineItem Type="Education"
23                   Description="Developer Conference"
24                   Cost="90" />
25         <LineItem Type="Travel"
26                   Description="Taxi"
27                   Cost="70" />
28         <LineItem Type="Travel"
29                   Description="Hotel"
30                   Cost="60" />
31       </ExpenseReport.LineItems>
32     </ExpenseReport>
33     <XmlDataProvider x:Key="CostCenters"
34                      XPath="/CostCenters/*">
35       <x:XData>
36         <CostCenters xmlns="">
37           <CostCenter Number="4032"
38                       Name="Sales" />
39           <CostCenter Number="4034"
40                       Name="Marketing" />
41           <CostCenter Number="5061"
42                       Name="Human Resources" />
43           <CostCenter Number="5062"
44                       Name="Research and Development" />
45         </CostCenters>
46       </x:XData>
47     </XmlDataProvider>
48     <XmlDataProvider x:Key="Employees"
49                      XPath="/Employees/*">
50       <x:XData>
51         <Employees xmlns="">
52           <Employee Name="Terry Adams"
53                     Type="FTE"
54                     EmployeeNumber="1" />
55           <Employee Name="Claire O&apos;Donnell"
56                     Type="FTE"
57                     EmployeeNumber="12345" />
58           <Employee Name="Palle Peterson"
59                     Type="FTE"
60                     EmployeeNumber="5678" />
61           <Employee Name="Amy E. Alberts"
62                     Type="CSG"
63                     EmployeeNumber="99222" />
64           <Employee Name="Stefan Hesse"
65                     Type="Vendor"
66                     EmployeeNumber="-" />
67         </Employees>
68       </x:XData>
69     </XmlDataProvider>
70     <Style x:Key="ButtonInFlow"
71        TargetType="{x:Type Button}">
72       <Setter Property="Margin"
73               Value="5" />
74     </Style>
75     <Style x:Key="Button"
76    TargetType="{x:Type Button}">
77       <Setter Property="Padding"
78               Value="5" />
79     </Style>
80     <Style x:Key="EmployeeList"
81            TargetType="{x:Type ListBox}">
82       <Setter Property="Margin"
83               Value="0,0,75,0" />
84     </Style>
85     <Style x:Key="HorizontalRadio"
86            TargetType="{x:Type ListBoxItem}">
87       <Setter Property="Margin"
88               Value="10" />
89       <Setter Property="Template">
90         <Setter.Value>
91           <ControlTemplate>
92             <RadioButton Focusable="false"
93                          Content="{TemplateBinding ContentPresenter.Content}"
94                          IsChecked="{Binding Path=IsSelected,RelativeSource={RelativeSource TemplatedParent},Mode=TwoWay}" />
95           </ControlTemplate>
96         </Setter.Value>
97       </Setter>
98     </Style>
99     <Style x:Key="HorizontalRadioList"
100            TargetType="{x:Type ListBox}">
101       <Setter Property="IsTabStop"
102               Value="False" />
103       <Setter Property="Grid.Column"
104               Value="1" />
105       <Setter Property="Grid.Row"
106               Value="4" />
107       <Setter Property="Height"
108               Value="40" />
109       <Setter Property="Margin"
110               Value="10" />
111       <Setter Property="Template">
112         <Setter.Value>
113           <ControlTemplate TargetType="{x:Type ListBox}">
114             <StackPanel KeyboardNavigation.TabNavigation="Once"
115                         IsItemsHost="True"
116                         Orientation="Horizontal" />
117           </ControlTemplate>
118         </Setter.Value>
119       </Setter>
120     </Style>
122     <Style x:Key="InputText"
123            TargetType="{x:Type TextBox}">
124       <Setter Property="Height"
125               Value="25px" />
126       <Setter Property="FontFamily"
127               Value="Trebuchet MS" />
128       <Setter Property="Foreground"
129               Value="#0066CC" />
130       <Setter Property="FontSize"
131               Value="10pt" />
132       <Setter Property="Margin"
133               Value="10,10,20,10" />
134       <Style.Triggers>
135         <Trigger Property="Validation.HasError" Value="true">
136           <Setter Property="ToolTip"
137             Value="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors)[0].ErrorContent}"/>
138         </Trigger>
139         <Trigger Property="Validation.HasError" Value="false">
140           <Setter Property="ToolTip"
141             Value="{Binding RelativeSource={RelativeSource Self}, Path=ToolTip.Content}"/>
142         </Trigger>
143       </Style.Triggers>
144     </Style>
146     <Style x:Key="Label"
147            TargetType="{x:Type Label}">
148       <Setter Property="Foreground"
149               Value="DarkSlateBlue" />
150       <Setter Property="FontSize"
151               Value="10pt" />
152       <Setter Property="FontFamily"
153               Value="arial" />
154       <Setter Property="FontWeight"
155               Value="bold" />
156       <Setter Property="Margin"
157               Value="0,3,10,0" />
158       <Setter Property="VerticalAlignment"
159               Value="Center" />
160       <Setter Property="HorizontalAlignment"
161               Value="Right" />
162     </Style>
163     <Style x:Key="DisplayText"
164            TargetType="{x:Type TextBlock}">
165       <Setter Property="Foreground"
166               Value="#4E87D4" />
167       <Setter Property="FontSize"
168               Value="14pt" />
169       <Setter Property="FontFamily"
170               Value="arial" />
171       <Setter Property="FontWeight"
172               Value="bold" />
173       <Setter Property="Margin"
174               Value="10,0,0,0" />
175       <Setter Property="HorizontalAlignment"
176               Value="left" />
177       <Setter Property="VerticalAlignment"
178               Value="center" />
179     </Style>
180     <Style x:Key="TitleText"
181            TargetType="{x:Type TextBlock}">
182       <Setter Property="FontSize"
183               Value="22pt" />
184       <Setter Property="Foreground"
185               Value="#4E87D4" />
186       <Setter Property="FontFamily"
187               Value="Trebuchet MS" />
188       <Setter Property="Margin"
189               Value="120,5,5,5" />
190       <Setter Property="Grid.Row"
191               Value="0" />
192       <Setter Property="Grid.Column"
193               Value="0" />
194       <Setter Property="Grid.ColumnSpan"
195               Value="2" />
196       <Setter Property="FontWeight"
197               Value="bold" />
198     </Style>
199     <Style x:Key="TableLabel"
200            TargetType="{x:Type TextBlock}">
201       <Setter Property="Foreground"
202               Value="white" />
203       <Setter Property="VerticalAlignment"
204               Value="Center" />
205       <Setter Property="HorizontalAlignment"
206               Value="Center" />
207       <Setter Property="FontWeight"
208               Value="bold" />
209       <Setter Property="FontSize"
210               Value="10pt" />
211     </Style>
212     <Style x:Key="TotalExpenses"
213            TargetType="{x:Type TextBlock}">
214       <Setter Property="FontSize"
215               Value="18pt" />
216       <Setter Property="Foreground"
217               Value="White" />
218       <Setter Property="Margin"
219               Value="0,10,30,10" />
220     </Style>
221     <Style x:Key="TotalExpensesFlow"
222            TargetType="{x:Type StackPanel}">
223       <Setter Property="Orientation"
224               Value="Horizontal" />
225       <Setter Property="HorizontalAlignment"
226               Value="Right" />
227     </Style>
228     <Style x:Key="TotalExpensesLabel"
229            TargetType="{x:Type TextBlock}">
230       <Setter Property="FontFamily"
231               Value="Trebuchet MS" />
232       <Setter Property="FontSize"
233               Value="14pt" />
234       <Setter Property="Margin"
235               Value="10,10,0,10" />
236       <Setter Property="Foreground"
237               Value="White" />
238     </Style>
239     <Style x:Key="TotalRectangle"
240            TargetType="{x:Type Rectangle}">
241       <Setter Property="Stroke">
242         <Setter.Value>
243           <LinearGradientBrush StartPoint="0,0"
244                                EndPoint="0,1">
245             <GradientBrush.GradientStops>
246               <GradientStopCollection>
247                 <GradientStop Color="#4E87D4"
248                               Offset="0" />
249                 <GradientStop Color="#73B2F5"
250                               Offset="1" />
251               </GradientStopCollection>
252             </GradientBrush.GradientStops>
253           </LinearGradientBrush>
254         </Setter.Value>
255       </Setter>
256       <Setter Property="StrokeThickness"
257               Value="1" />
258       <Setter Property="Fill">
259         <Setter.Value>
260           <LinearGradientBrush StartPoint="0,0"
261                                EndPoint="0,1">
262             <GradientBrush.GradientStops>
263               <GradientStopCollection>
264                 <GradientStop Color="#73B2F5"
265                               Offset="0" />
266                 <GradientStop Color="#4E87D4"
267                               Offset="1" />
268               </GradientStopCollection>
269             </GradientBrush.GradientStops>
270           </LinearGradientBrush>
271         </Setter.Value>
272       </Setter>
273       <Setter Property="RadiusX"
274               Value="10" />
275       <Setter Property="RadiusY"
276               Value="10" />
277     </Style>
278     <Style x:Key="WatermarkImage"
279            TargetType="{x:Type Image}">
280       <Setter Property="Source"
281               Value="watermark.png" />
282       <Setter Property="HorizontalAlignment"
283               Value="left" />
284       <Setter Property="VerticalAlignment"
285               Value="top" />
286       <Setter Property="Grid.Row"
287               Value="0" />
288       <Setter Property="Grid.RowSpan"
289               Value="5" />
290       <Setter Property="Grid.ColumnSpan"
291               Value="2" />
292       <Setter Property="Width"
293               Value="230" />
294       <Setter Property="Opacity"
295               Value="0.5" />
296     </Style>
297     <DataTemplate x:Key="EmployeeItemTemplate">
298       <TextBlock Text="{Binding XPath=@Name}" />
299     </DataTemplate>
301     <Style x:Key="ExpenseScroller"
302            TargetType="{x:Type ItemsControl}">
303       <Setter Property="Template">
304         <Setter.Value>
305           <ControlTemplate TargetType="{x:Type ItemsControl}">
306             <ScrollViewer VerticalScrollBarVisibility="Auto">
307               <StackPanel Orientation="vertical"
308                           IsItemsHost="true" />
309             </ScrollViewer>
310           </ControlTemplate>
311         </Setter.Value>
312       </Setter>
313     </Style>
315     <DataTemplate x:Key="ExpenseTemplate">
316       <Grid>
317         <Grid.ColumnDefinitions>
318           <ColumnDefinition Width="33*" />
319           <ColumnDefinition Width="33*" />
320           <ColumnDefinition Width="33*" />
321         </Grid.ColumnDefinitions>
322         <TextBox Text="{Binding Path=Type}"
323                  Grid.Column="0" />
324         <TextBox Text="{Binding Path=Description}"
325                  Grid.Column="1" />
326         <TextBox
327                  Grid.Column="2" >
328           <TextBox.Text>
329             <Binding Path="Cost" UpdateSourceTrigger="PropertyChanged">
330               <!-- SECURITY: Cost must be an int -->
331               <Binding.ValidationRules>
332                 <localValidation:NumberValidationRule />
333               </Binding.ValidationRules>
334             </Binding>
335           </TextBox.Text>
336         </TextBox>
338       </Grid>
339     </DataTemplate>
341     <DataTemplate x:Key="CostCenterTemplate">
342       <TextBlock Text="{Binding XPath=@Name}" />
343     </DataTemplate>
344     <Style x:Key="ExpenseChart"
345            TargetType="{x:Type ItemsControl}">
346       <Setter Property="DataContext"
347               Value="{DynamicResource ExpenseData}" />
348       <Setter Property="ItemsSource"
349               Value="{Binding Path=LineItems}" />
350       <Setter Property="ItemTemplate"
351               Value="{DynamicResource ExpenseChartBar}" />
352       <Setter Property="Template">
353         <Setter.Value>
354           <ControlTemplate TargetType="{x:Type ItemsControl}">
355             <Grid Width="{TemplateBinding Width}"
356                   Height="{TemplateBinding Height}">
357               <Rectangle Stroke="Black"
358                          StrokeThickness="1">
359                 <Rectangle.Fill>
360                   <LinearGradientBrush StartPoint="0,0"
361                                        EndPoint="0,1">
362                     <GradientBrush.GradientStops>
363                       <GradientStopCollection>
364                         <GradientStop Color="RoyalBlue"
365                                       Offset="0" />
366                         <GradientStop Color="#99ccff"
367                                       Offset="1" />
368                       </GradientStopCollection>
369                     </GradientBrush.GradientStops>
370                   </LinearGradientBrush>
371                 </Rectangle.Fill>
372               </Rectangle>
373               <Viewbox Margin="1"
374                        Stretch="Uniform">
375                 <StackPanel Orientation="Horizontal"
376                             IsItemsHost="True" />
377               </Viewbox>
378             </Grid>
379           </ControlTemplate>
380         </Setter.Value>
381       </Setter>
382     </Style>
383     <DataTemplate x:Key="ExpenseChartBar">
384       <Grid VerticalAlignment="Bottom"
385             Width="40">
386         <Grid.RowDefinitions>
387           <RowDefinition />
388           <RowDefinition Height="10" />
389         </Grid.RowDefinitions>
390         <Rectangle Grid.Row="0"
391                    Height="{Binding Path=Cost}"
392                    Margin="10,10,10,0"
393                    Fill="#33000000"
394                    RadiusX="2"
395                    RadiusY="2">
396           <Rectangle.RenderTransform>
397             <TranslateTransform X="1"
398                                 Y="1" />
399           </Rectangle.RenderTransform>
400         </Rectangle>
401         <Rectangle Grid.Row="0"
402                    Height="{Binding Path=Cost}"
403                    Margin="10,10,10,0"
404                    RadiusX="2"
405                    RadiusY="2"
406                    Stroke="black"
407                    StrokeThickness="0.5">
408           <Rectangle.Fill>
409             <RadialGradientBrush>
410               <GradientBrush.GradientStops>
411                 <GradientStopCollection>
412                   <GradientStop Color="LimeGreen"
413                                 Offset="0" />
414                   <GradientStop Color="DarkGreen"
415                                 Offset="1" />
416                 </GradientStopCollection>
417               </GradientBrush.GradientStops>
418             </RadialGradientBrush>
419           </Rectangle.Fill>
420         </Rectangle>
421         <Rectangle Grid.Row="0"
422                    Height="{Binding Path=Cost}"
423                    Margin="11,12,11,0"
424                    RadiusX="1"
425                    RadiusY="1">
426           <Rectangle.Fill>
427             <LinearGradientBrush StartPoint="0,0"
428                                  EndPoint="0,1">
429               <GradientBrush.GradientStops>
430                 <GradientStopCollection>
431                   <GradientStop Color="#aaffffff"
432                                 Offset="0" />
433                   <GradientStop Color="transparent"
434                                 Offset="1" />
435                 </GradientStopCollection>
436               </GradientBrush.GradientStops>
437             </LinearGradientBrush>
438           </Rectangle.Fill>
439         </Rectangle>
440         <Viewbox Grid.Row="1"
441                  Width="30"
442                  Margin="2">
443           <TextBlock Grid.Row="1"
444                      Width="100"
445                      FontSize="10pt"
446                      FontFamily="Arial"
447                      TextAlignment="center"
448                      TextTrimming="WordEllipsis"
449                      Text="{Binding Path=Description}" />
450         </Viewbox>
451         <TextBlock Margin="0,5,0,3"
452                    FontSize="4pt"
453                    FontFamily="Arial"
454                    TextAlignment="center"
455                    Foreground="white"
456                    Text="{Binding Path=Cost}" />
457       </Grid>
458     </DataTemplate>
459   </Application.Resources>
460 </Application>