Browse Source

Hacked around OmniXAML issue #84.

pull/464/head
Steven Kirk 11 years ago
parent
commit
cae6868b02
  1. 22
      src/Markup/Perspex.Markup.Xaml/MarkupExtensions/StyleResourceExtension.cs

22
src/Markup/Perspex.Markup.Xaml/MarkupExtensions/StyleResourceExtension.cs

@ -2,6 +2,7 @@
// Licensed under the MIT license. See licence.md file in the project root for full license information. // Licensed under the MIT license. See licence.md file in the project root for full license information.
using System; using System;
using System.Reactive.Linq;
using OmniXaml; using OmniXaml;
using Perspex.LogicalTree; using Perspex.LogicalTree;
using Perspex.Styling; using Perspex.Styling;
@ -25,7 +26,26 @@ namespace Perspex.Markup.Xaml.MarkupExtensions
$"StyleResource cannot be assigned to an object of type '{styleHost.GetType()}'."); $"StyleResource cannot be assigned to an object of type '{styleHost.GetType()}'.");
} }
return styleHost.FindStyleResource(Name); // HACK: This should be as simple as:
// return styleHost.FindStyleResource(Name);
// Waiting on OmniXAML issue #84 to be fixed before it can be that simple though.
var po = (PerspexObject)styleHost;
var parent = PerspexPropertyRegistry.Instance.FindRegistered(po, "Parent");
po.GetObservable(parent)
.Where(x => x != PerspexProperty.UnsetValue && x != null)
.Take(1)
.Subscribe(_ =>
{
var resource = styleHost.FindStyleResource(Name);
if (resource != PerspexProperty.UnsetValue)
{
extensionContext.TargetProperty.SetValue(extensionContext.TargetObject, resource);
}
});
return PerspexProperty.UnsetValue;
} }
public string Name { get; set; } public string Name { get; set; }

Loading…
Cancel
Save