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