Browse Source

Define FocusAdorner in XAML.

Steven Kirk 10 years ago
parent
commit
2f67a6d8d1

+ 9 - 0
samples/XamlTestApplicationPcl/FocusAdorner.paml

@@ -0,0 +1,9 @@
+<Style xmlns="https://github.com/perspex" Selector=":is(Control)">
+  <Setter Property="FocusAdorner">
+    <FocusAdornerTemplate>
+      <Rectangle Stroke="Black"
+                 StrokeThickness="1"
+                 StrokeDashArray="1,2"/>
+    </FocusAdornerTemplate>
+  </Setter>
+</Style>

+ 1 - 0
samples/XamlTestApplicationPcl/XamlTestApp.paml

@@ -2,6 +2,7 @@
         xmlns="https://github.com/perspex"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
   <Application.Styles>
+    <StyleInclude Source="resource://application/XamlTestApplicationPcl/XamlTestApplication.FocusAdorner.paml"/>
     <StyleInclude Source="resource://application/XamlTestApplicationPcl/XamlTestApplication.Button.paml"/>
     <StyleInclude Source="resource://application/XamlTestApplicationPcl/XamlTestApplication.Carousel.paml"/>
     <StyleInclude Source="resource://application/XamlTestApplicationPcl/XamlTestApplication.CheckBox.paml"/>

+ 3 - 0
samples/XamlTestApplicationPcl/XamlTestApplicationPcl.csproj

@@ -166,6 +166,9 @@
     <EmbeddedResource Include="TreeViewItem.paml">
       <SubType>Designer</SubType>
     </EmbeddedResource>
+    <EmbeddedResource Include="FocusAdorner.paml">
+      <SubType>Designer</SubType>
+    </EmbeddedResource>
     <None Include="packages.config" />
     <EmbeddedResource Include="Button.paml">
       <SubType>Designer</SubType>

+ 5 - 3
src/Markup/Perspex.Markup.Xaml/Context/PerspexObjectAssembler.cs

@@ -4,6 +4,7 @@
 using System;
 using OmniXaml;
 using OmniXaml.ObjectAssembler;
+using Perspex.Controls;
 using Perspex.Markup.Xaml.Templates;
 
 namespace Perspex.Markup.Xaml.Context
@@ -15,9 +16,10 @@ namespace Perspex.Markup.Xaml.Context
         public PerspexObjectAssembler(IWiringContext wiringContext, ObjectAssemblerSettings objectAssemblerSettings = null)
         {
             var mapping = new DeferredLoaderMapping();
-            mapping.Map<ControlTemplate>(template => template.Content, new TemplateLoader());
-            mapping.Map<DataTemplate>(template => template.Content, new TemplateLoader());
-            mapping.Map<TreeDataTemplate>(template => template.Content, new TemplateLoader());
+            mapping.Map<ControlTemplate>(x => x.Content, new TemplateLoader());
+            mapping.Map<DataTemplate>(x => x.Content, new TemplateLoader());
+            mapping.Map<FocusAdornerTemplate>(x => x.Content, new TemplateLoader());
+            mapping.Map<TreeDataTemplate>(x => x.Content, new TemplateLoader());
 
             var assembler = new ObjectAssembler(wiringContext, new TopDownValueContext(), objectAssemblerSettings);
             _objectAssembler = new TemplateHostingObjectAssembler(assembler, mapping);

+ 1 - 0
src/Markup/Perspex.Markup.Xaml/Perspex.Markup.Xaml.csproj

@@ -240,6 +240,7 @@
     <Compile Include="Parsers\SelectorGrammar.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="Styling\StyleInclude.cs" />
+    <Compile Include="Templates\FocusAdornerTemplate.cs" />
     <Compile Include="Templates\ControlTemplate.cs" />
     <Compile Include="Templates\MemberSelector.cs" />
     <Compile Include="Templates\TemplateLoader.cs" />

+ 0 - 1
src/Markup/Perspex.Markup.Xaml/Templates/ControlTemplate.cs

@@ -1,7 +1,6 @@
 // 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.Controls;
 using Perspex.Controls.Templates;
 using Perspex.Metadata;

+ 19 - 0
src/Markup/Perspex.Markup.Xaml/Templates/FocusAdornerTemplate.cs

@@ -0,0 +1,19 @@
+// 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 Perspex.Controls;
+using Perspex.Metadata;
+
+namespace Perspex.Markup.Xaml.Templates
+{
+    public class FocusAdornerTemplate : ITemplate<IControl>
+    {
+        [Content]
+        public TemplateContent Content { get; set; }
+
+        public IControl Build()
+        {
+            return Content.Load();
+        }
+    }
+}

+ 8 - 8
src/Perspex.Controls/Primitives/TemplatedControl.cs

@@ -25,49 +25,49 @@ namespace Perspex.Controls.Primitives
             Border.BackgroundProperty.AddOwner<TemplatedControl>();
 
         /// <summary>
-        /// Defines the <see cref="BorderBrushProperty"/> property.
+        /// Defines the <see cref="BorderBrush"/> property.
         /// </summary>
         public static readonly PerspexProperty<Brush> BorderBrushProperty =
             Border.BorderBrushProperty.AddOwner<TemplatedControl>();
 
         /// <summary>
-        /// Defines the <see cref="BorderThicknessProperty"/> property.
+        /// Defines the <see cref="BorderThickness"/> property.
         /// </summary>
         public static readonly PerspexProperty<double> BorderThicknessProperty =
             Border.BorderThicknessProperty.AddOwner<TemplatedControl>();
 
         /// <summary>
-        /// Defines the <see cref="FontFamilyProperty"/> property.
+        /// Defines the <see cref="FontFamily"/> property.
         /// </summary>
         public static readonly PerspexProperty<string> FontFamilyProperty =
             TextBlock.FontFamilyProperty.AddOwner<TemplatedControl>();
 
         /// <summary>
-        /// Defines the <see cref="FontSizeProperty"/> property.
+        /// Defines the <see cref="FontSize"/> property.
         /// </summary>
         public static readonly PerspexProperty<double> FontSizeProperty =
             TextBlock.FontSizeProperty.AddOwner<TemplatedControl>();
 
         /// <summary>
-        /// Defines the <see cref="FontStyleProperty"/> property.
+        /// Defines the <see cref="FontStyle"/> property.
         /// </summary>
         public static readonly PerspexProperty<FontStyle> FontStyleProperty =
             TextBlock.FontStyleProperty.AddOwner<TemplatedControl>();
 
         /// <summary>
-        /// Defines the <see cref="ForegroundProperty"/> property.
+        /// Defines the <see cref="Foreground"/> property.
         /// </summary>
         public static readonly PerspexProperty<Brush> ForegroundProperty =
             TextBlock.ForegroundProperty.AddOwner<TemplatedControl>();
 
         /// <summary>
-        /// Defines the <see cref="PaddingProperty"/> property.
+        /// Defines the <see cref="Padding"/> property.
         /// </summary>
         public static readonly PerspexProperty<Thickness> PaddingProperty =
             Decorator.PaddingProperty.AddOwner<TemplatedControl>();
 
         /// <summary>
-        /// Defines the <see cref="TemplateProperty"/> property.
+        /// Defines the <see cref="Template"/> property.
         /// </summary>
         public static readonly PerspexProperty<IControlTemplate> TemplateProperty =
             PerspexProperty.Register<TemplatedControl, IControlTemplate>("Template");