Browse Source
And add StyleInclude class to import it. Unfortunately doesn't work yet due to bug in OmniXAML: https://github.com/SuperJMN/OmniXAML/issues/48pull/297/head
9 changed files with 115 additions and 34 deletions
@ -0,0 +1,33 @@ |
|||
<Styles xmlns="https://github.com/perspex"> |
|||
<Style Selector="Button"> |
|||
<Setter Property="Background" Value="#ffaaaaaa"/> |
|||
<Setter Property="BorderBrush" Value="#ffaaaaaa"/> |
|||
<Setter Property="BorderThickness" Value="2"/> |
|||
<Setter Property="Foreground" Value="Black"/> |
|||
<Setter Property="HorizontalContentAlignment" Value="Center"/> |
|||
<Setter Property="VerticalContentAlignment" Value="Center"/> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate TargetType="Button"> |
|||
<Border Name="border" |
|||
Padding="3" |
|||
Background="{TemplateBinding Background}" |
|||
BorderBrush="{TemplateBinding BorderBrush}" |
|||
BorderThickness="{TemplateBinding BorderThickness}"> |
|||
<ContentPresenter Content="{TemplateBinding Content}" |
|||
TextBlock.Foreground="{TemplateBinding Foreground}" |
|||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" |
|||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/> |
|||
</Border> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
</Style> |
|||
<Style Selector="Button:pointerover /template/ Border#border"> |
|||
<Setter Property="BorderBrush" Value="#ff888888"/> |
|||
</Style> |
|||
<Style Selector="Button:pressed /template/ Border#border"> |
|||
<Setter Property="Background" Value="#ff888888"/> |
|||
</Style> |
|||
<Style Selector="Button:disabled"> |
|||
<Setter Property="Opacity" Value="0.5"/> |
|||
</Style> |
|||
</Styles> |
|||
@ -0,0 +1,32 @@ |
|||
// Copyright (c) The Perspex Project. All rights reserved.
|
|||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|||
|
|||
using System; |
|||
using System.Globalization; |
|||
using OmniXaml.TypeConversion; |
|||
|
|||
namespace Perspex.Markup.Xaml.Converters |
|||
{ |
|||
public class UriTypeConverter : ITypeConverter |
|||
{ |
|||
public bool CanConvertFrom(IXamlTypeConverterContext context, Type sourceType) |
|||
{ |
|||
return sourceType == typeof(string); |
|||
} |
|||
|
|||
public bool CanConvertTo(IXamlTypeConverterContext context, Type destinationType) |
|||
{ |
|||
return false; |
|||
} |
|||
|
|||
public object ConvertFrom(IXamlTypeConverterContext context, CultureInfo culture, object value) |
|||
{ |
|||
return new Uri((string)value); |
|||
} |
|||
|
|||
public object ConvertTo(IXamlTypeConverterContext context, CultureInfo culture, object value, Type destinationType) |
|||
{ |
|||
throw new NotImplementedException(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,39 @@ |
|||
// Copyright (c) The Perspex Project. All rights reserved.
|
|||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|||
|
|||
using System; |
|||
using Perspex.Styling; |
|||
|
|||
namespace Perspex.Markup.Xaml.Styling |
|||
{ |
|||
/// <summary>
|
|||
/// Includes a style from a URL.
|
|||
/// </summary>
|
|||
public class StyleInclude : IStyle |
|||
{ |
|||
/// <summary>
|
|||
/// Gets or sets the source URL.
|
|||
/// </summary>
|
|||
public Uri Source { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Gets the loaded style.
|
|||
/// </summary>
|
|||
public IStyle Loaded { get; private set; } |
|||
|
|||
/// <inheritdoc/>
|
|||
public void Attach(IStyleable control, IStyleHost container) |
|||
{ |
|||
if (Source != null) |
|||
{ |
|||
if (Loaded == null) |
|||
{ |
|||
var loader = new PerspexXamlLoader(); |
|||
Loaded = (IStyle)loader.Load(Source); |
|||
} |
|||
|
|||
Loaded.Attach(control, container); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue