PageRenderTime 31ms CodeModel.GetById 26ms app.highlight 1ms RepoModel.GetById 2ms app.codeStats 0ms

/V2.2/trunk/Quickstarts/EventAggregation/Silverlight/App.xaml

#
XAML | 95 lines | 65 code | 12 blank | 18 comment | 0 complexity | 7e2b6263c78f2889d24e40e826bf7eff MD5 | raw file
 1<Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 2             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
 3             x:Class="EventAggregation.App">
 4    <Application.Resources>
 5        <!-- NormalBrush is used as the Background for SimpleButton, SimpleRepeatButton -->
 6        <LinearGradientBrush x:Key="NormalBrush" EndPoint="0,1" StartPoint="0,0">
 7            <GradientStop Color="#EEE" Offset="0.0"/>
 8            <GradientStop Color="#CCC" Offset="1.0"/>
 9        </LinearGradientBrush>
10        <LinearGradientBrush x:Key="NormalBorderBrush" EndPoint="0,1" StartPoint="0,0">
11            <GradientStop Color="#CCC" Offset="0.0"/>
12            <GradientStop Color="#444" Offset="1.0"/>
13        </LinearGradientBrush>
14
15        <!-- Used for background of ScrollViewer, TreeView, ListBox, Expander, TextBox, Tab Control -->
16        <SolidColorBrush x:Key="WindowBackgroundBrush" Color="#FFF"/>
17
18        <!-- Used for Checkmark, Radio button, TreeViewItem, Expander ToggleButton glyphs -->
19        <SolidColorBrush x:Key="GlyphBrush" Color="#444"/>
20        <SolidColorBrush x:Key="SolidBorderBrush" Color="#888"/>
21
22        <!-- Simple Button - This control sets brushes on each state. Note that these brushes must be listed above since they are static resources -->
23        <Style x:Key="SimpleButton" TargetType="Button" >
24            <!--<Setter Property="FocusVisualStyle" Value="{StaticResource SimpleButtonFocusVisual}"/>-->
25            <Setter Property="Background" Value="{StaticResource NormalBrush}"/>
26            <Setter Property="BorderBrush" Value="{StaticResource NormalBorderBrush}"/>
27            <Setter Property="Template">
28                <Setter.Value>
29                    <ControlTemplate TargetType="Button">
30
31                        <!-- We use Grid as a root because it is easy to add more elements to customize the button -->
32                        <Grid x:Name="Grid">
33                            <Border x:Name="Border" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}"/>
34
35                            <!-- Content Presenter is where the text content etc is placed by the control -->
36                            <!-- The bindings are useful so that the control can be parameterized without editing the template -->
37                            <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
38                        </Grid>
39                    </ControlTemplate>
40                </Setter.Value>
41            </Setter>
42        </Style>
43
44        <!-- Simple ComboBox Toggle Button - This is used in ComboBox to expand and collapse the ComboBox Popup-->
45        <ControlTemplate x:Key="ComboBoxToggleButton" TargetType="ToggleButton">
46            <Grid>
47                <Grid.ColumnDefinitions>
48                    <ColumnDefinition/>
49                    <ColumnDefinition Width="20"/>
50                </Grid.ColumnDefinitions>
51                <Rectangle Grid.ColumnSpan="2" HorizontalAlignment="Stretch" x:Name="Rectangle" VerticalAlignment="Stretch" Width="Auto" Height="Auto" RadiusX="5" RadiusY="5" Fill="{StaticResource NormalBrush}" Stroke="{StaticResource NormalBorderBrush}"/>
52                <Rectangle Grid.Column="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="Auto" Height="Auto" RadiusX="5" RadiusY="5" Fill="{StaticResource WindowBackgroundBrush}" Stroke="{StaticResource NormalBorderBrush}"/>
53                <Path Grid.Column="1" HorizontalAlignment="Center" x:Name="Arrow" VerticalAlignment="Center" Fill="{StaticResource GlyphBrush}" Data="M 0 0 L 4 4 L 8 0 Z"/>
54            </Grid>
55        </ControlTemplate>
56
57        <ControlTemplate x:Key="ComboBoxTextBox" TargetType="TextBox">
58            <!-- This must be named as PART_ContentHost -->
59            <Border x:Name="PART_ContentHost" Background="{TemplateBinding Background}"/>
60        </ControlTemplate>
61
62        <Style x:Key="SimpleComboBox" TargetType="ComboBox">
63            <Setter Property="Template">
64                <Setter.Value>
65                    <ControlTemplate TargetType="ComboBox">
66                        <Grid>
67                            <!-- The ToggleButton is databound to the ComboBox itself to toggle IsDropDownOpen -->
68                            <!--<ToggleButton Grid.Column="2" Template="{StaticResource ComboBoxToggleButton}" x:Name="ToggleButton" IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" ClickMode="Press"/>-->
69                            <ToggleButton Grid.Column="2" Template="{StaticResource ComboBoxToggleButton}" x:Name="ToggleButton" ClickMode="Press"/>
70                            <ContentPresenter HorizontalAlignment="Left" Margin="3,3,23,3" x:Name="ContentSite" VerticalAlignment="Center" Content="{TemplateBinding SelectionBoxItem}" ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}" IsHitTestVisible="False"/>
71
72                            <!-- The TextBox must be named PART_EditableTextBox or ComboBox will not recognize it -->
73                            <!--<TextBox Visibility="Collapsed"  Template="{StaticResource ComboBoxTextBox}" HorizontalAlignment="Left" Margin="3,3,23,3" x:Name="PART_EditableTextBox" Style="{x:Null}" VerticalAlignment="Center" Background="Transparent" IsReadOnly="{TemplateBinding IsReadOnly}"/>-->
74                            <TextBox Visibility="Collapsed"  Template="{StaticResource ComboBoxTextBox}" HorizontalAlignment="Left" Margin="3,3,23,3" x:Name="PART_EditableTextBox" Style="{x:Null}" VerticalAlignment="Center" Background="Transparent" />
75
76                            <!-- The Popup shows the list of items in the ComboBox. IsOpen is databound to IsDropDownOpen which is toggled via the ComboBoxToggleButton -->
77                            <Popup IsOpen="{TemplateBinding IsDropDownOpen}" VerticalAlignment="Bottom" x:Name="Popup">
78                                <Grid MaxHeight="{TemplateBinding MaxDropDownHeight}" MinWidth="{TemplateBinding ActualWidth}" x:Name="DropDown" >
79                                    <Border x:Name="DropDownBorder" Background="{StaticResource WindowBackgroundBrush}" BorderBrush="{StaticResource SolidBorderBrush}" BorderThickness="1"/>
80                                    <!--<ScrollViewer Margin="4,6,4,6" Style="{StaticResource SimpleScrollViewer}" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">-->
81                                    <ScrollViewer Margin="4,6,4,6" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
82
83                                        <!-- The StackPanel is used to display the children by setting IsItemsHost to be True -->
84                                        <!--<StackPanel  IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Contained"/>-->
85
86                                    </ScrollViewer>
87                                </Grid>
88                            </Popup>
89                        </Grid>
90                    </ControlTemplate>
91                </Setter.Value>
92            </Setter>
93        </Style>
94    </Application.Resources>
95</Application>