mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
Avalonia ControlThemes
This commit is contained in:
parent
a02abb7f76
commit
4608f9a511
|
|
@ -1,12 +1,18 @@
|
|||
<Styles xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:map="clr-namespace:MapControl">
|
||||
<ResourceDictionary
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:map="clr-namespace:MapControl">
|
||||
|
||||
<!-- Style replaced by TemplateProperty and ItemsPanelProperty default value overrides -->
|
||||
<!--
|
||||
<Style Selector="map|MapItemsControl">
|
||||
<ControlTheme TargetType="{x:Type map:MapBase}" x:Key="{x:Type map:MapBase}">
|
||||
<Setter Property="Background" Value="White"/>
|
||||
<Setter Property="Foreground" Value="Black"/>
|
||||
</ControlTheme>
|
||||
|
||||
<ControlTheme TargetType="{x:Type map:Map}" x:Key="{x:Type map:Map}" BasedOn="{StaticResource {x:Type map:MapBase}}"/>
|
||||
|
||||
<ControlTheme TargetType="{x:Type map:MapItemsControl}" x:Key="{x:Type map:MapItemsControl}">
|
||||
<Setter Property="Template">
|
||||
<ControlTemplate>
|
||||
<ControlTemplate TargetType="{x:Type map:MapItemsControl}">
|
||||
<ItemsPresenter ItemsPanel="{TemplateBinding ItemsPanel}"/>
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
|
|
@ -17,37 +23,64 @@
|
|||
</ItemsPanelTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
-->
|
||||
</ControlTheme>
|
||||
|
||||
<Style Selector="map|MapContentControl">
|
||||
<ControlTheme TargetType="{x:Type ContentControl}" x:Key="ContentControlTheme">
|
||||
<Setter Property="Background" Value="{Binding Background, RelativeSource={RelativeSource AncestorType=map:MapBase}}"/>
|
||||
<Setter Property="BorderBrush" Value="{Binding Foreground, RelativeSource={RelativeSource AncestorType=map:MapBase}}"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Center"/>
|
||||
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Stretch"/>
|
||||
<Setter Property="VerticalAlignment" Value="Stretch"/>
|
||||
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
|
||||
<Setter Property="VerticalContentAlignment" Value="Stretch"/>
|
||||
<Setter Property="ClipToBounds" Value="False"/>
|
||||
|
||||
<!-- Template Setter here somehow disables a Template Setter in a Style for a derived type, e.g. MapItem -->
|
||||
<!--<Setter Property="Template">
|
||||
<ControlTemplate TargetType="{x:Type ContentControl}">
|
||||
<ContentPresenter
|
||||
Content="{TemplateBinding Content}"
|
||||
ContentTemplate="{TemplateBinding ContentTemplate}"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
Margin="{TemplateBinding Padding}"/>
|
||||
</ControlTemplate>
|
||||
</Setter>-->
|
||||
</ControlTheme>
|
||||
|
||||
<ControlTheme TargetType="{x:Type map:MapContentControl}" x:Key="{x:Type map:MapContentControl}" BasedOn="{StaticResource ContentControlTheme}">
|
||||
<Setter Property="Template">
|
||||
<ControlTemplate>
|
||||
<ContentPresenter Content="{TemplateBinding Content}"
|
||||
ContentTemplate="{TemplateBinding ContentTemplate}"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
Margin="{TemplateBinding Padding}"/>
|
||||
<ControlTemplate TargetType="{x:Type map:MapContentControl}">
|
||||
<ContentPresenter
|
||||
Content="{TemplateBinding Content}"
|
||||
ContentTemplate="{TemplateBinding ContentTemplate}"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
Margin="{TemplateBinding Padding}"/>
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
</Style>
|
||||
</ControlTheme>
|
||||
|
||||
<Style Selector="map|Pushpin">
|
||||
<Setter Property="Background" Value="{Binding Background, RelativeSource={RelativeSource AncestorType=map:MapBase}}"/>
|
||||
<Setter Property="BorderBrush" Value="{Binding Foreground, RelativeSource={RelativeSource AncestorType=map:MapBase}}"/>
|
||||
<ControlTheme TargetType="{x:Type map:MapItem}" x:Key="{x:Type map:MapItem}" BasedOn="{StaticResource ContentControlTheme}">
|
||||
<Setter Property="Template">
|
||||
<ControlTemplate TargetType="{x:Type map:MapItem}">
|
||||
<ContentPresenter
|
||||
Content="{TemplateBinding Content}"
|
||||
ContentTemplate="{TemplateBinding ContentTemplate}"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
Margin="{TemplateBinding Padding}"/>
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
</ControlTheme>
|
||||
|
||||
<ControlTheme TargetType="{x:Type map:Pushpin}" x:Key="{x:Type map:Pushpin}" BasedOn="{StaticResource ContentControlTheme}">
|
||||
<Setter Property="HorizontalAlignment" Value="Center"/>
|
||||
<Setter Property="VerticalAlignment" Value="Bottom"/>
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
<Setter Property="CornerRadius" Value="5"/>
|
||||
<Setter Property="Padding" Value="7,5"/>
|
||||
<Setter Property="Template">
|
||||
<ControlTemplate>
|
||||
<ControlTemplate TargetType="{x:Type map:Pushpin}">
|
||||
<map:PushpinBorder
|
||||
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
|
||||
Background="{TemplateBinding Background}"
|
||||
|
|
@ -63,5 +96,5 @@
|
|||
</map:PushpinBorder>
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
</Style>
|
||||
</Styles>
|
||||
</ControlTheme>
|
||||
</ResourceDictionary>
|
||||
|
|
|
|||
|
|
@ -31,12 +31,13 @@
|
|||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="ContentControl">
|
||||
<ContentPresenter Content="{TemplateBinding Content}"
|
||||
ContentTemplate="{TemplateBinding ContentTemplate}"
|
||||
ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
Margin="{TemplateBinding Padding}"/>
|
||||
<ContentPresenter
|
||||
Content="{TemplateBinding Content}"
|
||||
ContentTemplate="{TemplateBinding ContentTemplate}"
|
||||
ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
Margin="{TemplateBinding Padding}"/>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
|
|
|
|||
|
|
@ -35,12 +35,13 @@
|
|||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="ContentControl">
|
||||
<ContentPresenter Content="{TemplateBinding Content}"
|
||||
ContentTemplate="{TemplateBinding ContentTemplate}"
|
||||
ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
Margin="{TemplateBinding Padding}"/>
|
||||
<ContentPresenter
|
||||
Content="{TemplateBinding Content}"
|
||||
ContentTemplate="{TemplateBinding ContentTemplate}"
|
||||
ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
Margin="{TemplateBinding Padding}"/>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
|
|
|
|||
|
|
@ -31,12 +31,13 @@
|
|||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="ContentControl">
|
||||
<ContentPresenter Content="{TemplateBinding Content}"
|
||||
ContentTemplate="{TemplateBinding ContentTemplate}"
|
||||
ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
Margin="{TemplateBinding Padding}"/>
|
||||
<ContentPresenter
|
||||
Content="{TemplateBinding Content}"
|
||||
ContentTemplate="{TemplateBinding ContentTemplate}"
|
||||
ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
Margin="{TemplateBinding Padding}"/>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
|
|
|
|||
|
|
@ -2,8 +2,14 @@
|
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
x:Class="SampleApplication.App"
|
||||
RequestedThemeVariant="Light">
|
||||
<Application.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceInclude Source="avares://MapControl.Avalonia/Themes/Generic.axaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</Application.Resources>
|
||||
<Application.Styles>
|
||||
<FluentTheme />
|
||||
<StyleInclude Source="avares://MapControl.Avalonia/Themes/Generic.axaml"/>
|
||||
</Application.Styles>
|
||||
</Application>
|
||||
|
|
|
|||
|
|
@ -16,6 +16,38 @@
|
|||
ManipulationModes="All"
|
||||
DoubleTapped="MapDoubleTapped">
|
||||
|
||||
<map:MapItemsControl ItemsSource="{Binding Polylines}">
|
||||
<map:MapItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<map:MapPolyline Locations="{Binding Locations}" Stroke="Red" StrokeThickness="3"/>
|
||||
</DataTemplate>
|
||||
</map:MapItemsControl.ItemTemplate>
|
||||
</map:MapItemsControl>
|
||||
|
||||
<map:MapItemsControl ItemsSource="{Binding Points}"
|
||||
SelectionMode="Multiple">
|
||||
<map:MapItemsControl.Styles>
|
||||
<Style Selector="map|MapItem">
|
||||
<Setter Property="map:MapPanel.Location" Value="{Binding Location}"/>
|
||||
</Style>
|
||||
<Style Selector="map|MapItem:selected">
|
||||
<Setter Property="Foreground" Value="OrangeRed"/>
|
||||
</Style>
|
||||
</map:MapItemsControl.Styles>
|
||||
<map:MapItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Canvas Width="100" Height="100" ClipToBounds="False">
|
||||
<Path StrokeThickness="2" Stroke="Gray" Fill="Transparent">
|
||||
<Path.Data>
|
||||
<EllipseGeometry RadiusX="8" RadiusY="8"/>
|
||||
</Path.Data>
|
||||
</Path>
|
||||
<TextBlock Margin="16,-9,0,0" Text="{Binding Name}"/>
|
||||
</Canvas>
|
||||
</DataTemplate>
|
||||
</map:MapItemsControl.ItemTemplate>
|
||||
</map:MapItemsControl>
|
||||
|
||||
<map:MapItemsControl ItemsSource="{Binding Pushpins}"
|
||||
SelectedItem="{Binding SelectedPushpin}"
|
||||
SelectionMode="Multiple"
|
||||
|
|
@ -28,8 +60,9 @@
|
|||
<Setter Property="HorizontalAlignment" Value="Center"/>
|
||||
<Setter Property="VerticalAlignment" Value="Bottom"/>
|
||||
<Setter Property="Template">
|
||||
<ControlTemplate>
|
||||
<map:Pushpin Content="{Binding Name}"/>
|
||||
<ControlTemplate TargetType="map:MapItem">
|
||||
<map:Pushpin Content="{Binding Name}"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"/>
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ namespace SampleApplication
|
|||
Points.Add(new PointItem
|
||||
{
|
||||
Name = "Buhne 10",
|
||||
Location = new Location(53.49350, 8.15563)
|
||||
Location = new Location(53.49348, 8.15694)
|
||||
});
|
||||
|
||||
Pushpins.Add(new PointItem
|
||||
|
|
|
|||
Loading…
Reference in a new issue