Closed jevonsflash closed 3 months ago
I defined and validated implicit styles in the ResourceDictionary in App.xaml and TestPopup.xaml.
The validation results when the style is defined in App.xaml are shown below. Since the github repository was not made public, I do not know how LightCard BackgroundColor and BackCare BackgroundColor were defined, but I defined them as follows.
[App.xaml]
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:Maui_PasswordEntryTest"
x:Class="PopupTest.App">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Resources/Styles/Colors.xaml" />
<ResourceDictionary Source="Resources/Styles/Styles.xaml" />
</ResourceDictionary.MergedDictionaries>
<Color x:Key="LightCardBackgroundColor">Blue</Color>
<Color x:Key="DarkCardBackgroundColor">Red</Color>
<Style TargetType="{x:Type Border}">
<Setter Property="StrokeShape" Value="RoundRectangle 5" />
<Setter Property="Stroke" Value="{AppThemeBinding Light={StaticResource LightCardBackgroundColor}, Dark={StaticResource DarkCardBackgroundColor}}" />
<Setter Property="BackgroundColor" Value="{AppThemeBinding Light={StaticResource LightCardBackgroundColor}, Dark={StaticResource DarkCardBackgroundColor}}" />
</Style>
</ResourceDictionary>
</Application.Resources>
</Application>
[TestPopup.xaml]
<?xml version="1.0" encoding="utf-8" ?>
<toolkit:Popup xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
x:Class="PopupTest.TestPopup"
Size="200,200"
Color="Transparent"
VerticalOptions="End"
HorizontalOptions="Fill">
<Border>
</Border>
</toolkit:Popup>
https://github.com/CommunityToolkit/Maui/assets/125236133/10cba6c0-094e-4f5c-b462-81f42aef7851
The verification results when the style is defined in TestPopup.xaml are shown below.
[TestPopup.xaml]
<?xml version="1.0" encoding="utf-8" ?>
<toolkit:Popup xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
x:Class="PopupTest.TestPopup"
Size="200,200"
Color="Transparent"
VerticalOptions="End"
HorizontalOptions="Fill">
<toolkit:Popup.Resources>
<ResourceDictionary>
<Color x:Key="LightCardBackgroundColor">Blue</Color>
<Color x:Key="DarkCardBackgroundColor">Red</Color>
<Style TargetType="{x:Type Border}">
<Setter Property="StrokeShape" Value="RoundRectangle 5" />
<Setter Property="Stroke" Value="{AppThemeBinding Light={StaticResource LightCardBackgroundColor}, Dark={StaticResource DarkCardBackgroundColor}}" />
<Setter Property="BackgroundColor" Value="{AppThemeBinding Light={StaticResource LightCardBackgroundColor}, Dark={StaticResource DarkCardBackgroundColor}}" />
</Style>
</ResourceDictionary>
</toolkit:Popup.Resources>
<Border>
</Border>
</toolkit:Popup>
https://github.com/CommunityToolkit/Maui/assets/125236133/be747f94-8afa-47f9-928e-6eef2d2c6d7e
No exceptions occurred in either case.
By the way, the theme at the time of verification was light.
@jevonsflash , I get a 404 error when I try to browse the repository. Is this repository public?
Hi @jevonsflash. We have added the "needs reproduction" label to this issue, which indicates that we cannot take further action. This issue will be closed automatically in 5 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.
Thanks @cat0363 for testing and trying to reproduce the issue, I have added the label: needs reproduction and waiting for feedback from @jevonsflash, to know if this issue is still active or no.
This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 3 days. It will be closed if no further activity occurs within 2 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.
We haven't received a reproduction sample from you. The issue is closed.
Is there an existing issue for this?
Did you read the "Reporting a bug" section on Contributing file?
Current Behavior
When the ShowPopup method is called, the following error occurs:
Expected Behavior
the popup view appears.
Steps To Reproduce
Create a Style in the ResourceDictionary like this:
And create a popup control like this:
It's worth mentioning that when Stlye is not defined anonymously, The program runs normally
this is Ok:
Link to public reproduction project repository
https://github.com/jevonsflash/MatoProductivity
Environment
Anything else?
The stack information for InnerException is printed as follows:
在 WinRT.ExceptionHelpers.gThrow|39_0(Int32 hr)
在 ABI.Microsoft.UI.Xaml.IFrameworkElementMethods.get_ActualWidth(IObjectReference _obj)
在 Microsoft.UI.Xaml.FrameworkElement.get_ActualWidth()
在 Microsoft.Maui.Platform.ContentPanel.UpdateBorder(IShape strokeShape)
在 Microsoft.Maui.Platform.ContentPanel.UpdateBorderStroke(IBorderStroke borderStroke)
在 Microsoft.Maui.Platform.StrokeExtensions.UpdateStrokeShape(ContentPanel platformView, IBorderStroke border)
在 Microsoft.Maui.Handlers.BorderHandler.MapStrokeShape(IBorderHandler handler, IBorderView border)
在 Microsoft.Maui.Handlers.ElementHandler.UpdateValue(String property)
在 Microsoft.Maui.Controls.Border.OnPropertyChanged(String propertyName)
在 Microsoft.Maui.Controls.Border.b 15_0(Object sender, PropertyChangedEventArgs e)
在 Microsoft.Maui.Controls.WeakNotifyPropertyChangedProxy.OnPropertyChanged(Object sender, PropertyChangedEventArgs e)
在 Microsoft.Maui.Controls.Element.OnPropertyChanged(String propertyName)
在 Microsoft.Maui.Controls.Shapes.RoundRectangle.OnPropertyChanged(String propertyName)
在 Microsoft.Maui.Controls.Element.SetParent(Element value)
在 Microsoft.Maui.Controls.Element.OnChildAdded(Element child)
在 Microsoft.Maui.Controls.VisualElement.OnChildAdded(Element child)
在 Microsoft.Maui.Controls.Element.AddLogicalChild(Element element)
在 Microsoft.Maui.Controls.Border.NotifyStrokeShapeChanges()
在 Microsoft.Maui.Controls.Border.<>c.<.cctor>b78_0(BindableObject bindable, Object oldvalue, Object newvalue)
在 Microsoft.Maui.Controls.BindableObject.SetValueActual(BindableProperty property, BindablePropertyContext context, Object value, Boolean currentlyApplying, SetValueFlags attributes, SetterSpecificity specificity, Boolean silent)
在 Microsoft.Maui.Controls.BindableObject.SetValueCore(BindableProperty property, Object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes, SetterSpecificity specificity)
在 Microsoft.Maui.Controls.BindableObject.SetValue(BindableProperty property, Object value, SetterSpecificity specificity)
在 Microsoft.Maui.Controls.Setter.Apply(BindableObject target, SetterSpecificity specificity)
在 Microsoft.Maui.Controls.Style.ApplyCore(BindableObject bindable, Style basedOn, SetterSpecificity specificity)
在 Microsoft.Maui.Controls.Style.Microsoft.Maui.Controls.IStyle.Apply(BindableObject bindable, SetterSpecificity specificity)
在 Microsoft.Maui.Controls.MergedStyle.SetStyle(IStyle implicitStyle, IList`1 classStyles, IStyle style)
在 Microsoft.Maui.Controls.MergedStyle.set_ImplicitStyle(IStyle value)
在 Microsoft.Maui.Controls.MergedStyle.OnImplicitStyleChanged()
在 Microsoft.Maui.Controls.MergedStyle.b 31_0(BindableObject bindable, Object oldvalue, Object newvalue)
在 Microsoft.Maui.Controls.BindableObject.SetValueActual(BindableProperty property, BindablePropertyContext context, Object value, Boolean currentlyApplying, SetValueFlags attributes, SetterSpecificity specificity, Boolean silent)
在 Microsoft.Maui.Controls.BindableObject.SetValueCore(BindableProperty property, Object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes, SetterSpecificity specificity)
在 Microsoft.Maui.Controls.Element.OnResourceChanged(BindableProperty property, Object value, SetterSpecificity specificity)
在 Microsoft.Maui.Controls.Element.OnSetDynamicResource(BindableProperty property, String key, SetterSpecificity specificity)
在 Microsoft.Maui.Controls.BindableObject.SetDynamicResource(BindableProperty property, String key, SetterSpecificity specificity)
在 Microsoft.Maui.Controls.BindableObject.SetDynamicResource(BindableProperty property, String key)
在 Microsoft.Maui.Controls.MergedStyle.RegisterImplicitStyles()
在 Microsoft.Maui.Controls.MergedStyle..ctor(Type targetType, BindableObject target)
在 Microsoft.Maui.Controls.NavigableElement..ctor()
在 Microsoft.Maui.Controls.VisualElement..ctor()
在 Microsoft.Maui.Controls.View..ctor()
在 Microsoft.Maui.Controls.Border..ctor()
在 System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean wrapExceptions)