Browse Source

Move listbox/listview styles that highlight the focus instead of the selection to GlobalStyles.

pull/6/merge
Daniel Grunwald 14 years ago
parent
commit
6f6a97acca
  1. 32
      src/AddIns/Misc/SharpRefactoring/Project/Src/Gui/InsertCtorDialog.xaml
  2. 34
      src/AddIns/Misc/SharpRefactoring/Project/Src/Gui/OverrideToStringMethodDialog.xaml
  3. 20
      src/Main/ICSharpCode.Core.Presentation/GlobalStyles.cs
  4. 58
      src/Main/ICSharpCode.Core.Presentation/themes/generic.xaml

32
src/AddIns/Misc/SharpRefactoring/Project/Src/Gui/InsertCtorDialog.xaml

@ -8,34 +8,6 @@ @@ -8,34 +8,6 @@
<gui:AbstractInlineRefactorDialog.Resources>
<gui:IntToBoolConverter x:Key="intToBoolConverter" />
<Style TargetType="Button" BasedOn="{x:Static sd:GlobalStyles.ButtonStyle}"/>
<Style x:Key="ListViewItemFocusHighlight" TargetType="{x:Type ListViewItem}">
<!-- This style replaces the default ListViewItem template with one that highlights the focused item instead of the selected items -->
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListViewItem}">
<Border Name="Bd"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Padding="{TemplateBinding Padding}"
SnapsToDevicePixels="true">
<GridViewRowPresenter Content="{TemplateBinding Content}" Columns="{TemplateBinding GridView.ColumnCollection}"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsKeyboardFocusWithin"
Value="true">
<Setter TargetName="Bd"
Property="Background"
Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
<Setter Property="Foreground"
Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</gui:AbstractInlineRefactorDialog.Resources>
<Grid Cursor="Arrow" KeyboardNavigation.TabNavigation="Cycle">
<Grid.RowDefinitions>
@ -46,7 +18,9 @@ @@ -46,7 +18,9 @@
<TextBlock Margin="3"
Text="{sd:Localize AddIns.SharpRefactoring.InsertCtor.Description}"
TextWrapping="Wrap" />
<ListView x:Name="varList" Grid.Row="1" SelectionMode="Multiple" KeyboardNavigation.TabNavigation="Cycle" ItemContainerStyle="{StaticResource ListViewItemFocusHighlight}" MaxHeight="300">
<ListView x:Name="varList" Grid.Row="1"
SelectionMode="Multiple" KeyboardNavigation.TabNavigation="Cycle"
ItemContainerStyle="{x:Static sd:GlobalStyles.ListViewItemFocusHighlightStyle}" MaxHeight="300">
<ListView.View>
<GridView>
<GridViewColumn Header="{sd:Localize AddIns.SharpRefactoring.InsertCtor.VariableLabel}">

34
src/AddIns/Misc/SharpRefactoring/Project/Src/Gui/OverrideToStringMethodDialog.xaml

@ -6,37 +6,6 @@ @@ -6,37 +6,6 @@
xmlns:widgets="http://icsharpcode.net/sharpdevelop/widgets"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid Cursor="Arrow" KeyboardNavigation.TabNavigation="Cycle">
<Grid.Resources>
<Style x:Key="ListBoxItemFocusHighlight" TargetType="{x:Type ListBoxItem}">
<!-- This style replaces the default ListBoxItem template with one that highlights the focused item instead of the selected item -->
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListBoxItem}">
<Border Name="Bd"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Padding="{TemplateBinding Padding}"
SnapsToDevicePixels="true">
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsKeyboardFocusWithin"
Value="true">
<Setter TargetName="Bd"
Property="Background"
Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
<Setter Property="Foreground"
Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
@ -45,7 +14,8 @@ @@ -45,7 +14,8 @@
<TextBlock Margin="3"
Text="{sd:Localize AddIns.SharpRefactoring.OverrideToStringMethod.Description}"
TextWrapping="Wrap" />
<ListBox Grid.Row="1" Margin="4" SelectionMode="Multiple" ItemContainerStyle="{StaticResource ListBoxItemFocusHighlight}" x:Name="listBox">
<ListBox x:Name="listBox" Grid.Row="1" Margin="4" SelectionMode="Multiple"
ItemContainerStyle="{x:Static sd:GlobalStyles.ListBoxItemFocusHighlightStyle}">
<ListBox.ItemTemplate>
<DataTemplate>
<!-- The checkbox is toggling the actual IsSelected property on the container (ListBoxItem), so it'll update ListBox.SelectedItems -->

20
src/Main/ICSharpCode.Core.Presentation/GlobalStyles.cs

@ -65,5 +65,25 @@ namespace ICSharpCode.Core.Presentation @@ -65,5 +65,25 @@ namespace ICSharpCode.Core.Presentation
public static ResourceKey FlowDirectionKey {
get { return flowDirectionKey; }
}
static readonly ResourceKey listViewItemFocusHighlightStyleKey = new ComponentResourceKey(typeof(GlobalStyles), "ListViewItemFocusHighlightStyle");
public static ResourceKey ListViewItemFocusHighlightStyleKey {
get { return listViewItemFocusHighlightStyleKey; }
}
public static Style ListViewItemFocusHighlightStyle {
get { return FindResource(listViewItemFocusHighlightStyleKey); }
}
static readonly ResourceKey listBoxItemFocusHighlightStyleKey = new ComponentResourceKey(typeof(GlobalStyles), "ListBoxItemFocusHighlightStyle");
public static ResourceKey ListBoxItemFocusHighlightStyleKey {
get { return listBoxItemFocusHighlightStyleKey; }
}
public static Style ListBoxItemFocusHighlightStyle {
get { return FindResource(listBoxItemFocusHighlightStyleKey); }
}
}
}

58
src/Main/ICSharpCode.Core.Presentation/themes/generic.xaml

@ -208,4 +208,62 @@ @@ -208,4 +208,62 @@
Data = "M 5,5 L 10,10 L 15,5 L 5,5"/>
</StackPanel>
</DataTemplate>
<Style x:Key="{x:Static local:GlobalStyles.ListBoxItemFocusHighlightStyleKey}" TargetType="{x:Type ListBoxItem}">
<!-- This style replaces the default ListBoxItem template with one that highlights the focused item instead of the selected item -->
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListBoxItem}">
<Border Name="Bd"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Padding="{TemplateBinding Padding}"
SnapsToDevicePixels="true">
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsKeyboardFocusWithin"
Value="true">
<Setter TargetName="Bd"
Property="Background"
Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
<Setter Property="Foreground"
Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="{x:Static local:GlobalStyles.ListViewItemFocusHighlightStyleKey}" TargetType="{x:Type ListViewItem}">
<!-- This style replaces the default ListViewItem template with one that highlights the focused item instead of the selected items -->
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListViewItem}">
<Border Name="Bd"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Padding="{TemplateBinding Padding}"
SnapsToDevicePixels="true">
<GridViewRowPresenter Content="{TemplateBinding Content}" Columns="{TemplateBinding GridView.ColumnCollection}"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsKeyboardFocusWithin"
Value="true">
<Setter TargetName="Bd"
Property="Background"
Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
<Setter Property="Foreground"
Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
Loading…
Cancel
Save