Commits

Mark Heath  committed 8096383

Styled the module select button

  • Participants
  • Parent commits 9c138cc

Comments (0)

Files changed (4)

File ModularWPFTest/App.xaml

              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
              Startup="Application_Startup">
     <Application.Resources>
-         
+        <ResourceDictionary>
+            <ResourceDictionary.MergedDictionaries>
+                <ResourceDictionary Source="ModuleButtonStyle.xaml"/>
+            </ResourceDictionary.MergedDictionaries>
+        </ResourceDictionary>
     </Application.Resources>
 </Application>

File ModularWPFTest/MainWindow.xaml

             <ColumnDefinition Width="30*"></ColumnDefinition>
             <ColumnDefinition Width="80*"></ColumnDefinition>
         </Grid.ColumnDefinitions>
-        <ItemsControl x:Name="listBox" Grid.Column="0" 
+        <Border BorderThickness="1" BorderBrush="#808080">
+        <ItemsControl x:Name="listBox" Grid.Column="0"
                  ItemsSource="{Binding Modules}" >
             <ItemsControl.ItemTemplate>
                 <DataTemplate>
                     <Button Content="{Binding Name}" 
                             Command="{Binding DataContext.SelectModuleCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ItemsControl}}}" 
-                            CommandParameter="{Binding}" />
+                            CommandParameter="{Binding}"                            
+                            Style="{StaticResource ResourceKey=ModuleButtonStyle}"/>
                 </DataTemplate>
             </ItemsControl.ItemTemplate>
         </ItemsControl>
+        </Border>
         <ContentPresenter x:Name="contentPresenter" Grid.Column="1" 
                           Content="{Binding UserInterface}" />
     </Grid>

File ModularWPFTest/ModularWPFTest.csproj

       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
+    <Page Include="ModuleButtonStyle.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
   </ItemGroup>
   <ItemGroup>
     <Compile Include="Module1\Module1.cs" />

File ModularWPFTest/ModuleButtonStyle.xaml

+<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
+    <Style x:Key="ModuleButtonStyle" TargetType="{x:Type Button}">
+        <Setter Property="SnapsToDevicePixels" Value="true"/>
+        <Setter Property="OverridesDefaultStyle" Value="true"/>
+        <Setter Property="MinHeight" Value="23"/>
+        <Setter Property="MinWidth" Value="75"/>
+        <Setter Property="Background" Value="#FFFFD0"/>
+        <Setter Property="Template">
+            <Setter.Value>
+                <ControlTemplate TargetType="{x:Type Button}">
+                    <Border 
+                          x:Name="Border"  
+                          Background="{TemplateBinding Background}"
+                          BorderBrush="#404040">
+                        <ContentPresenter 
+                            Margin="2"
+                            HorizontalAlignment="Center"
+                            VerticalAlignment="Center"
+                            RecognizesAccessKey="True"/>
+                    </Border>
+                    <ControlTemplate.Triggers>
+                        <Trigger Property="IsMouseOver" Value="true">
+                            <Setter TargetName="Border" Property="Background" Value="#E0E080" />
+                        </Trigger>
+                        <Trigger Property="IsPressed" Value="true">
+                            <Setter TargetName="Border" Property="Background" Value="#D0D060" />
+                        </Trigger>
+                    </ControlTemplate.Triggers>
+                </ControlTemplate>
+            </Setter.Value>
+        </Setter>
+    </Style>
+</ResourceDictionary>