added SSCLI 1.0
[windows-sources.git] / sdk / samples / WPFSamples / TrafficAlert / csharp / window1.xaml
blobec462e99b32b7861daaf854c0fae79c42eeb1f85
1 <Window x:Class="TrafficAlert.Window1"
2     xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' 
3     xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'
4     Title="Traffic Alert"
5   
6     ShowInTaskbar="true"
7     Name ="w1"
8     Loaded="WindowLoaded"
9     Background="beige" 
10     Width="400"
11     Height ="700" >
12   
13   <StackPanel Name="sp">
15     <StackPanel.Resources>
16       
17     <Style x:Key="ExpandCollapseToggleStyle"
18        TargetType="{x:Type ToggleButton}">
19       <Setter Property="Focusable"
20               Value="False"/>
21       <Setter Property="Width"
22               Value="19"/>
23       <Setter Property="Height"
24               Value="13"/>
25         <Setter Property="Template">
26           <Setter.Value>
27             <ControlTemplate TargetType="{x:Type ToggleButton}">
28               <Border Width="19"
29                       Height="13"
30                       Background="transparent">
31                 <Border Width="11"
32                         Height="11"
33                         BorderThickness="1"
34                         BorderBrush="black"
35                         CornerRadius="25"
36                         SnapsToDevicePixels="true">
37                   <Border.Background>
38                     <LinearGradientBrush StartPoint="0,0"
39                                          EndPoint="1,1">
40                       <LinearGradientBrush.GradientStops>
41                         <GradientStop Color="YELLOW"
42                                       Offset=".2"/>
43                         <GradientStop Color="RED"
44                                       Offset="1"/>
45                       </LinearGradientBrush.GradientStops>
46                     </LinearGradientBrush>
47                   </Border.Background>
48                   <Path x:Name="ExpandPath"
49                         Margin="2,2,2,2"
50                         Fill="black"
51                         Data="M 0 2 L 0 3 L 2 3 L 2 5 L 3 5 L 3 3 L 5 3 L 5 2 L 3 2 L 3 0 L 2 0 L 2 2 Z"/>
52                 </Border>
53               </Border>
54               <ControlTemplate.Triggers>
55                 <Trigger Property="IsChecked"
56                          Value="True">
57                   <Setter Property="Data"
58                           TargetName="ExpandPath"
59                           Value="M 0 2 L 0 3 L 5 3 L 5 2 Z"/>
60                 </Trigger>
61               </ControlTemplate.Triggers>
62             </ControlTemplate>
63           </Setter.Value>
64         </Setter>
65       </Style>
67       <Style x:Key="TreeViewItemFocusVisual">
68         <Setter Property="Control.Template">
69           <Setter.Value>
70             <ControlTemplate>
71               <Border>
72                 <Rectangle Margin="0,0,0,0"
73                            StrokeThickness="5"
74                            Stroke="Black"
75                            StrokeDashArray="1 2"
76                            Opacity="0"/>
77               </Border>
78             </ControlTemplate>
79           </Setter.Value>
80         </Setter>
81       </Style>
82       
83       <Style x:Key="{x:Type TreeViewItem}"
84              TargetType="{x:Type TreeViewItem}">
85         <Setter Property="Background"
86         Value="Transparent"/>
87         <Setter Property="HorizontalContentAlignment"
88                 Value="{Binding Path=HorizontalContentAlignment,RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
89         <Setter Property="VerticalContentAlignment"
90                 Value="{Binding Path=VerticalContentAlignment,RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
91         <Setter Property="Padding"
92                 Value="1,0,0,0"/>
93         <Setter Property="Foreground"
94                 Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
95         <Setter Property="FocusVisualStyle"
96                 Value="{StaticResource TreeViewItemFocusVisual}"/>
97         <Setter Property="Template">
98           <Setter.Value>
99             <ControlTemplate TargetType="{x:Type TreeViewItem}">
100               <Grid>
101                 <Grid.ColumnDefinitions>
102                   <ColumnDefinition MinWidth="19"
103                                     Width="Auto"/>
104                   <ColumnDefinition Width="Auto"/>
105                   <ColumnDefinition Width="*"/>
106                 </Grid.ColumnDefinitions>
107                 <Grid.RowDefinitions>
108                   <RowDefinition Height="Auto"/>
109                   <RowDefinition/>
110                 </Grid.RowDefinitions>
111                 <ToggleButton x:Name="Expander"
112                               Style="{StaticResource ExpandCollapseToggleStyle}"
113                               IsChecked="{Binding Path=IsExpanded,RelativeSource={RelativeSource TemplatedParent}}"
114                               ClickMode="Press"/>
115                 <Border Name="Bd"
116                         Grid.Column="1"
117                         Background="{TemplateBinding Background}"
118                         BorderBrush="{TemplateBinding BorderBrush}"
119                         BorderThickness="{TemplateBinding BorderThickness}"
120                         Padding="{TemplateBinding Padding}">
121                   <ContentPresenter x:Name="PART_Header"
122                                     ContentSource="Header"
123                                     HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"/>
124                 </Border>
125                 <ItemsPresenter x:Name="ItemsHost"
126                                 Grid.Row="1"
127                                 Grid.Column="1"
128                                 Grid.ColumnSpan="2"/>
129               </Grid>
130               <ControlTemplate.Triggers>
131                 <Trigger Property="IsExpanded"
132                          Value="false">
133                   <Setter TargetName="ItemsHost"
134                           Property="Visibility"
135                           Value="Collapsed"/>
136                 </Trigger>
137                 <Trigger Property="HasItems"
138                          Value="false">
139                   <Setter TargetName="Expander"
140                           Property="Visibility"
141                           Value="Hidden"/>
142                 </Trigger>
143                 <MultiTrigger>
144                   <MultiTrigger.Conditions>
145                     <Condition Property="HasHeader"
146                                Value="false"/>
147                     <Condition Property="Width"
148                                Value="Auto"/>
149                   </MultiTrigger.Conditions>
150                   <Setter TargetName="PART_Header"
151                           Property="MinWidth"
152                           Value="75"/>
153                 </MultiTrigger>
154                 <MultiTrigger>
155                   <MultiTrigger.Conditions>
156                     <Condition Property="HasHeader"
157                                Value="false"/>
158                     <Condition Property="Height"
159                                Value="Auto"/>
160                   </MultiTrigger.Conditions>
161                   <Setter TargetName="PART_Header"
162                           Property="MinHeight"
163                           Value="19"/>
164                 </MultiTrigger>
165                 <Trigger Property="IsSelected"
166                          Value="true">
167                   <Setter TargetName="Bd"
168                           Property="Background"
169                           Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
170                   <Setter Property="Foreground"
171                           Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}"/>
172                 </Trigger>
173                 <MultiTrigger>
174                   <MultiTrigger.Conditions>
175                     <Condition Property="IsSelected"
176                                Value="true"/>
177                     <Condition Property="IsSelectionActive"
178                                Value="false"/>
179                   </MultiTrigger.Conditions>
180                   <Setter TargetName="Bd"
181                           Property="Background"
182                           Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
183                   <Setter Property="Foreground"
184                           Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
185                 </MultiTrigger>
186                 <Trigger Property="IsEnabled"
187                          Value="false">
188                   <Setter Property="Foreground"
189                           Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
190                 </Trigger>
191               </ControlTemplate.Triggers>
192             </ControlTemplate>
193           </Setter.Value>
194         </Setter>
195       </Style>
196       
197       <Style x:Key="{x:Type TreeView}"
198            TargetType="{x:Type TreeView}">
200         <Setter Property="Template">
201           <Setter.Value>
202             <ControlTemplate TargetType="{x:Type TreeView}">
203               <Border Name="Bd"
204                       BorderBrush="{TemplateBinding BorderBrush}"
205                       BorderThickness="{TemplateBinding BorderThickness}"
206                       >
207                 <ScrollViewer 
208                               Focusable="FALSE"
209                               CanContentScroll="false"
210                               HorizontalScrollBarVisibility="Hidden" 
211                               VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}"
212                               Padding="{TemplateBinding Padding}">
213                   <ScrollViewer.Background>
214                     <LinearGradientBrush>
215                       <LinearGradientBrush.StartPoint>
216                         <Point X="0" Y="0"/>
217                       </LinearGradientBrush.StartPoint>
218                       <LinearGradientBrush.EndPoint>
219                         <Point X="1" Y="1"/>
220                       </LinearGradientBrush.EndPoint>
221                       <LinearGradientBrush.GradientStops>
222                         <GradientStop Color="red" Offset="0"/>
223                         <GradientStop Color="black" Offset="1.15"/>
224                       </LinearGradientBrush.GradientStops>
225                     </LinearGradientBrush>
226                   </ScrollViewer.Background>
227                   <ItemsPresenter/>
228                 </ScrollViewer>
229               </Border>
230               <ControlTemplate.Triggers>
231                 <MultiTrigger>
232                   <MultiTrigger.Conditions>
233                     <Condition Property="HasItems"
234                                Value="false"/>
235                     <Condition Property="Width"
236                                Value="Auto"/>
237                   </MultiTrigger.Conditions>
238                   <Setter Property="MinWidth"
239                           Value="120"/>
240                 </MultiTrigger>
241                 <MultiTrigger>
242                   <MultiTrigger.Conditions>
243                     <Condition Property="HasItems"
244                                Value="false"/>
245                     <Condition Property="Height"
246                                Value="Auto"/>
247                   </MultiTrigger.Conditions>
248                   <Setter Property="MinHeight"
249                           Value="95"/>
250                 </MultiTrigger>
251               </ControlTemplate.Triggers>
252             </ControlTemplate>
253           </Setter.Value>
254         </Setter>
255       </Style>
257     
258     </StackPanel.Resources>
259     
260     
261     <WrapPanel>
262       <Rectangle Stroke="black" Fill="orangered" Height="12" Width="12"/>
263       <Label>Critical</Label>
264       <Rectangle Stroke="black" Fill="Orange" Height="12" Width="12"/>
265       <Label>Major</Label>
266       <Rectangle Stroke="black" Fill="Yellow" Height="12" Width="12"/>
267       <Label>Minor</Label>
268       <Button Name="ZipCode" Click="ButtonClick">
269         <Button.Background>
270             <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
271               <LinearGradientBrush.GradientStops>
272                 <GradientStopCollection>
273                   <GradientStop Color="red" Offset="0" />
274                   <GradientStop Color="yellow" Offset="1" />
275                 </GradientStopCollection>
276               </LinearGradientBrush.GradientStops>
277             </LinearGradientBrush>
278         </Button.Background>       
279        ZipCode</Button>
280     </WrapPanel>
281     <Label Name="Location" FontWeight="bold"/>
282     <ScrollViewer HorizontalScrollBarVisibility="auto" VerticalScrollBarVisibility="hidden" Name="sv">
283       <TreeView Name="tv"   BorderThickness="0" SizeChanged="tv_SizeChanged">
286       </TreeView>
287     </ScrollViewer>
288   </StackPanel>
289 </Window>