PageRenderTime 33ms CodeModel.GetById 8ms RepoModel.GetById 1ms app.codeStats 0ms

/V4/Quickstarts/Modularity/Desktop/ModularityWithUnity/ModularityWithUnity.Desktop/ModularityStyles.xaml

#
XAML | 85 lines | 73 code | 8 blank | 4 comment | 0 complexity | 3560c083c95cbc72e73f01aec05688e5 MD5 | raw file
  1. <ResourceDictionary
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
  5. xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
  6. xmlns:ModularityWithUnity="clr-namespace:ModularityWithUnity.Desktop">
  7. <SolidColorBrush x:Key="ModuleControl.NotStarted.BackgroundBrush-Simple" Color="White"/>
  8. <SolidColorBrush x:Key="ModuleControl.NotStarted.BorderBrush-Simple" Color="Gray"/>
  9. <SolidColorBrush x:Key="ModuleControl.NotStarted.ForegroundBrush-Simple" Color="Gray"/>
  10. <SolidColorBrush x:Key="ModuleControl.Downloading.BackgroundBrush-Simple" Color="White"/>
  11. <SolidColorBrush x:Key="ModuleControl.Downloading.BorderBrush-Simple" Color="LightBlue"/>
  12. <SolidColorBrush x:Key="ModuleControl.Downloading.ForegroundBrush-Simple" Color="Black"/>
  13. <LinearGradientBrush x:Key="ModuleControl.Downloaded.BackgroundBrush-Simple" EndPoint="0.5,1" StartPoint="0.5,0">
  14. <GradientStop Color="White" Offset="0.02"/>
  15. <GradientStop Color="LightBlue" Offset="1"/>
  16. </LinearGradientBrush>
  17. <SolidColorBrush x:Key="ModuleControl.Downloaded.BorderBrush-Simple" Color="LightBlue"/>
  18. <SolidColorBrush x:Key="ModuleControl.Downloaded.ForegroundBrush-Simple" Color="Black"/>
  19. <SolidColorBrush x:Key="ModuleControl.Constructed.BackgroundBrush-Simple" Color="White"/>
  20. <SolidColorBrush x:Key="ModuleControl.Constructed.BorderBrush-Simple" Color="Black"/>
  21. <SolidColorBrush x:Key="ModuleControl.Constructed.ForegroundBrush-Simple" Color="Black"/>
  22. <LinearGradientBrush x:Key="ModuleControl.Initialized.BackgroundBrush-Simple" EndPoint="0.5,1" StartPoint="0.5,0">
  23. <GradientStop Color="#FFBCE4A5" Offset="0.02"/>
  24. <GradientStop Color="#FF579D2F" Offset="1"/>
  25. </LinearGradientBrush>
  26. <SolidColorBrush x:Key="ModuleControl.Initialized.BorderBrush-Simple" Color="#FF36621D"/>
  27. <SolidColorBrush x:Key="ModuleControl.Initialized.ForegroundBrush-Simple" Color="Black"/>
  28. <ControlTemplate x:Key="ModuleControlTemplate-Simple" TargetType="ModularityWithUnity:ModuleControl">
  29. <Border x:Name="border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}">
  30. <i:Interaction.Triggers>
  31. <!-- DataTriggers only work when the dependency property value changes. -->
  32. <!-- For the quickstart, some modules may initialize before the UI data-binds. -->
  33. <!-- To accomodate this, the data triggers below bind to a hidden control value that is bound late enough. -->
  34. <ei:DataTrigger Binding="{Binding ElementName=ModuleStatusTextBlock, Path=Text}" Value="NotStarted">
  35. <ei:ChangePropertyAction PropertyName="Background" TargetObject="{Binding RelativeSource={RelativeSource TemplatedParent}}" Value="{StaticResource ModuleControl.NotStarted.BackgroundBrush-Simple}"/>
  36. <ei:ChangePropertyAction PropertyName="Foreground" TargetObject="{Binding RelativeSource={RelativeSource TemplatedParent}}" Value="{StaticResource ModuleControl.NotStarted.ForegroundBrush-Simple}"/>
  37. <ei:ChangePropertyAction PropertyName="BorderBrush" TargetObject="{Binding RelativeSource={RelativeSource TemplatedParent}}" Value="{StaticResource ModuleControl.NotStarted.BorderBrush-Simple}"/>
  38. <ei:ChangePropertyAction PropertyName="FontSize" TargetObject="{Binding RelativeSource={RelativeSource TemplatedParent}}" Value="12"/>
  39. </ei:DataTrigger>
  40. <ei:DataTrigger Binding="{Binding ElementName=ModuleStatusTextBlock, Path=Text}" Value="Downloading">
  41. <ei:ChangePropertyAction PropertyName="Background" TargetObject="{Binding RelativeSource={RelativeSource TemplatedParent}}" Value="{StaticResource ModuleControl.Downloading.BackgroundBrush-Simple}"/>
  42. <ei:ChangePropertyAction PropertyName="Foreground" TargetObject="{Binding RelativeSource={RelativeSource TemplatedParent}}" Value="{StaticResource ModuleControl.Downloading.ForegroundBrush-Simple}"/>
  43. <ei:ChangePropertyAction PropertyName="BorderBrush" TargetObject="{Binding RelativeSource={RelativeSource TemplatedParent}}" Value="{StaticResource ModuleControl.Downloading.BorderBrush-Simple}"/>
  44. </ei:DataTrigger>
  45. <ei:DataTrigger Binding="{Binding ElementName=ModuleStatusTextBlock, Path=Text}" Value="Downloaded">
  46. <ei:ChangePropertyAction PropertyName="Background" TargetObject="{Binding RelativeSource={RelativeSource TemplatedParent}}" Value="{StaticResource ModuleControl.Downloaded.BackgroundBrush-Simple}"/>
  47. <ei:ChangePropertyAction PropertyName="Foreground" TargetObject="{Binding RelativeSource={RelativeSource TemplatedParent}}" Value="{StaticResource ModuleControl.Downloaded.ForegroundBrush-Simple}"/>
  48. <ei:ChangePropertyAction PropertyName="BorderBrush" TargetObject="{Binding RelativeSource={RelativeSource TemplatedParent}}" Value="{StaticResource ModuleControl.Downloaded.BorderBrush-Simple}"/>
  49. </ei:DataTrigger>
  50. <ei:DataTrigger Binding="{Binding ElementName=ModuleStatusTextBlock, Path=Text}" Value="Constructed">
  51. <ei:ChangePropertyAction PropertyName="Background" TargetObject="{Binding RelativeSource={RelativeSource TemplatedParent}}" Value="{StaticResource ModuleControl.Constructed.BackgroundBrush-Simple}"/>
  52. <ei:ChangePropertyAction PropertyName="Foreground" TargetObject="{Binding RelativeSource={RelativeSource TemplatedParent}}" Value="{StaticResource ModuleControl.Constructed.ForegroundBrush-Simple}"/>
  53. <ei:ChangePropertyAction PropertyName="BorderBrush" TargetObject="{Binding RelativeSource={RelativeSource TemplatedParent}}" Value="{StaticResource ModuleControl.Constructed.BorderBrush-Simple}"/>
  54. <ei:ChangePropertyAction PropertyName="FontSize" TargetObject="{Binding RelativeSource={RelativeSource TemplatedParent}}" Value="12"/>
  55. </ei:DataTrigger>
  56. <ei:DataTrigger Binding="{Binding ElementName=ModuleStatusTextBlock, Path=Text}" Value="Initialized">
  57. <ei:ChangePropertyAction PropertyName="Background" TargetObject="{Binding RelativeSource={RelativeSource TemplatedParent}}" Value="{StaticResource ModuleControl.Initialized.BackgroundBrush-Simple}"/>
  58. <ei:ChangePropertyAction PropertyName="Foreground" TargetObject="{Binding RelativeSource={RelativeSource TemplatedParent}}" Value="{StaticResource ModuleControl.Initialized.ForegroundBrush-Simple}"/>
  59. <ei:ChangePropertyAction PropertyName="BorderBrush" TargetObject="{Binding RelativeSource={RelativeSource TemplatedParent}}" Value="{StaticResource ModuleControl.Initialized.BorderBrush-Simple}"/>
  60. <ei:ChangePropertyAction PropertyName="FontSize" TargetObject="{Binding RelativeSource={RelativeSource TemplatedParent}}" Value="15"/>
  61. </ei:DataTrigger>
  62. </i:Interaction.Triggers>
  63. <Grid>
  64. <ContentPresenter x:Name="contentPresenter" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" RenderTransformOrigin="0.5,0.5" />
  65. <!-- This must come after the DataTriggers so that it is bound later and causes the triggers to fire and grab initial state -->
  66. <TextBlock Visibility="Collapsed" x:Name="ModuleStatusTextBlock" Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=DataContext.ModuleInitializationStatus}" />
  67. </Grid>
  68. </Border>
  69. </ControlTemplate>
  70. <Style x:Key="ModuleControlStyle-Simple" TargetType="ModularityWithUnity:ModuleControl">
  71. <Setter Property="Background" Value="{StaticResource ModuleControl.NotStarted.BackgroundBrush-Simple}"/>
  72. <Setter Property="Foreground" Value="{StaticResource ModuleControl.NotStarted.ForegroundBrush-Simple}"/>
  73. <Setter Property="BorderBrush" Value="{StaticResource ModuleControl.NotStarted.BorderBrush-Simple}"/>
  74. <Setter Property="BorderThickness" Value="1" />
  75. <Setter Property="Template" Value="{StaticResource ModuleControlTemplate-Simple}"/>
  76. </Style>
  77. </ResourceDictionary>