Browse Source

Fixed NullReferenceExceptions.

pull/464/head
Steven Kirk 11 years ago
parent
commit
5348c23e4b
  1. 2
      src/Markup/Perspex.Markup.Xaml/Converters/PerspexPropertyTypeConverter.cs
  2. 2
      src/Markup/Perspex.Markup.Xaml/MarkupExtensions/StyleResourceExtension.cs

2
src/Markup/Perspex.Markup.Xaml/Converters/PerspexPropertyTypeConverter.cs

@ -36,7 +36,7 @@ namespace Perspex.Markup.Xaml.Converters
{ {
var styleType = context.TypeRepository.GetByType(typeof(Style)); var styleType = context.TypeRepository.GetByType(typeof(Style));
var style = (Style)context.TopDownValueContext.GetLastInstance(styleType); var style = (Style)context.TopDownValueContext.GetLastInstance(styleType);
type = style.Selector.TargetType; type = style.Selector?.TargetType;
if (type == null) if (type == null)
{ {

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

@ -23,7 +23,7 @@ namespace Perspex.Markup.Xaml.MarkupExtensions
if (styleHost == null) if (styleHost == null)
{ {
throw new ParseException( throw new ParseException(
$"StyleResource cannot be assigned to an object of type '{styleHost.GetType()}'."); $"StyleResource cannot be assigned to an object of type '{extensionContext.TargetObject.GetType()}'.");
} }
// HACK: This should be as simple as: // HACK: This should be as simple as:

Loading…
Cancel
Save