typeInfo.GetCustomAttribute<ContentPropertyAttribute>() returns null
See original GitHub issueI have migrated a Windows Store 8.1 application to UWP using this guide from Windows. During this migration process It was required to remove all existing project references and to manually install them again using Nuget. (Previously installed version- 2.0.2) But when I install the latest version from Nuget (Version - 3.2.0) I’m getting the following error when opening popups.
Code used to create and open Popups
public virtual void ShowPopup(object rootModel, object context = null, IDictionary<string, object> settings = null)
{
var popup = this.CreatePopup(rootModel, settings);
var view = ViewLocator.LocateForModel(rootModel, popup, context);
popup.Child = view;
popup.SetValue(View.IsGeneratedProperty, true);
ViewModelBinder.Bind(rootModel, popup, null);
Caliburn.Micro.Action.SetTargetWithoutContext(view, rootModel);
var activatable = rootModel as IActivate;
if (activatable != null)
{
activatable.Activate();
}
var deactivator = rootModel as IDeactivate;
if (deactivator != null)
{
popup.Closed += (object sender, object e) => { deactivator.Deactivate(true); };
}
popup.IsOpen = true;
}
However I was able to clone this repository and debug to the point of exception. It seems that this particular code (line 390) in View.cs returns null.
var contentProperty = typeInfo.GetCustomAttribute<ContentPropertyAttribute>();
But when I replaced the current code with the corresponding code snippet in 2.0.2 (line 362) It works perfectly.
var contentProperty = typeInfo.CustomAttributes
.FirstOrDefault(a => a.AttributeType == typeof(ContentPropertyAttribute));
return contentProperty == null ?
DefaultContentPropertyName :
contentProperty.NamedArguments[0].TypedValue.Value.ToString();
I would like to know if there is a workaround. Thanks in advance.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
Thanks for the extra info.
The following is the XAML template we used for the Popup. All the popups in the application are similar to this. The type of Popup used is
.I assume that this is what you are looking for, or else please let me know.