Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Icons does not appearing when using Style and Trigger Setter's #85

Open
Tracked by #109
uom42 opened this issue Mar 3, 2024 · 9 comments · May be fixed by #109
Open
Tracked by #109

Icons does not appearing when using Style and Trigger Setter's #85

uom42 opened this issue Mar 3, 2024 · 9 comments · May be fixed by #109
Assignees
Milestone

Comments

@uom42
Copy link

uom42 commented Mar 3, 2024

Describe the bug
If the Label.Text property is set from XAML markup - the icons is displayed.
But if the Text property is set from Style.Setter, the icons is not displayed.

To Reproduce
Set Label.Text property in XAML markup:
<Label Text="{mi:MaterialOutlined Icon=ArrowDropUp, IconColor={StaticResource Primary}}" />
result:
Screenshot_1709437268

use Styles:

<Label>
	<Label.Style>
		<Style TargetType="Label">
			<Setter Property="Text" Value="{mi:MaterialOutlined Icon=ArrowDropDown, IconColor={StaticResource Primary}}" />
		</Style>
	</Label.Style>
</Label>

result:
Screenshot_1709437320

Expected behavior
use Styles:

<Label>
	<Label.Style>
		<Style TargetType="Label">
			<Setter Property="Text" Value="{mi:MaterialOutlined Icon=ArrowDropDown, IconColor={StaticResource Primary}}" />
		</Style>
	</Label.Style>
</Label>

result:
Screenshot_1709437268

Additional context
API33 Android 13.0
net8.0-android

@uom42 uom42 changed the title Icon Fonts not showing up in Unpackaged Windows Deployment Icons does not appearing when using Style.Setter Mar 3, 2024
@AathifMahir AathifMahir self-assigned this Mar 3, 2024
@AathifMahir AathifMahir added Bug Something isn't working Area-Extensions labels Mar 3, 2024
@AathifMahir
Copy link
Owner

Describe the bug
If the Label.Text property is set from XAML markup - the icons is displayed.
But if the Text property is set from Style.Setter, the icons is not displayed.

To Reproduce
Set Label.Text property in XAML markup:
<Label Text="{mi:MaterialOutlined Icon=ArrowDropUp, IconColor={StaticResource Primary}}" />
result:
Screenshot_1709437268

use Styles:

<Label>
	<Label.Style>
		<Style TargetType="Label">
			<Setter Property="Text" Value="{mi:MaterialOutlined Icon=ArrowDropDown, IconColor={StaticResource Primary}}" />
		</Style>
	</Label.Style>
</Label>

result:
Screenshot_1709437320

Expected behavior
use Styles:

<Label>
	<Label.Style>
		<Style TargetType="Label">
			<Setter Property="Text" Value="{mi:MaterialOutlined Icon=ArrowDropDown, IconColor={StaticResource Primary}}" />
		</Style>
	</Label.Style>
</Label>

result:
Screenshot_1709437268

Additional context
API33 Android 13.0
net8.0-android

Thanks for reporting, I guess this scenario is rarely used, seems like we don't have test for it yet or nor a complete implementation to support style setter. Will release a patch with fix for this as soon as possible.

@AathifMahir AathifMahir added the Enhancement New feature or request label Mar 3, 2024
@uom42
Copy link
Author

uom42 commented Mar 4, 2024

...I guess this scenario is rarely used...

I think this should have widespread use:

You can use Setter's not only with styles (I just gave styles as an example), but also in triggers - they have the same Setter's.
For example, buttons that change their state (icon) - now I am forced to create several buttons and hide unnecessary ones, instead of just changing the button icon through a trigger.

@uom42 uom42 changed the title Icons does not appearing when using Style.Setter Icons does not appearing when using Style and Trigger Setter's Mar 4, 2024
@AathifMahir
Copy link
Owner

AathifMahir commented Mar 4, 2024

...I guess this scenario is rarely used...

I think this should have widespread use:

You can use Setter's not only with styles (I just gave styles as an example), but also in triggers - they have the same Setter's.
For example, buttons that change their state (icon) - now I am forced to create several buttons and hide unnecessary ones, instead of just changing the button icon through a trigger.

Yeah, I know

When we setting up a roadmap for v2, there's no request regarding support for multitrigger, triggers or setter support from devs. Therefore we mainly focused on supporting Xaml Markup Extension Across Different Controls.

Anyway, this feature request would be great starting point for supporting all Maui triggers and setters.

I'd really appreciate, if you share me sample of Xaml that uses Multitrigger, Single trigger and Setters that covers the whole use case.

@AathifMahir AathifMahir removed the Bug Something isn't working label Mar 4, 2024
@AathifMahir AathifMahir added this to the v2.2.0 milestone Mar 4, 2024
@AathifMahir AathifMahir modified the milestones: v2.2.0, v2.5.0 May 3, 2024
@Blackfishbox
Copy link

Hey, is this fixed in v3.0.0?

@AathifMahir
Copy link
Owner

Hey, is this fixed in v3.0.0?

This feature is not part of v3

@kezack
Copy link

kezack commented Jul 14, 2024

Hello,
I really appreciate your library,
I too have this problem with the setter,
here is my example in order to have another case.

<Label
         HorizontalOptions="Center"
         HorizontalTextAlignment="Center"
         Text="{mi:FontAwesomeSolid Icon=ChevronDown, IconColor={StaticResource PrimaryColor}}"                                                
         VerticalOptions="Center"
         VerticalTextAlignment="Center">
   <Label.Triggers>
       <DataTrigger
           Binding="{Binding Source={RelativeSource AncestorType={x:Type toolkit:Expander}}, Path=IsExpanded}"
           TargetType="Label"
           Value="True">
           <Setter Property="Text" Value="{mi:FontAwesomeSolid Icon=ChevronUp, IconColor={StaticResource PrimaryColor}}" />
       </DataTrigger>
   </Label.Triggers>
</Label>

@AathifMahir
Copy link
Owner

AathifMahir commented Jul 15, 2024

Hello,
I really appreciate your library,
I too have this problem with the setter,
here is my example in order to have another case.

<Label
         HorizontalOptions="Center"
         HorizontalTextAlignment="Center"
         Text="{mi:FontAwesomeSolid Icon=ChevronDown, IconColor={StaticResource PrimaryColor}}"                                                
         VerticalOptions="Center"
         VerticalTextAlignment="Center">
   <Label.Triggers>
       <DataTrigger
           Binding="{Binding Source={RelativeSource AncestorType={x:Type toolkit:Expander}}, Path=IsExpanded}"
           TargetType="Label"
           Value="True">
           <Setter Property="Text" Value="{mi:FontAwesomeSolid Icon=ChevronUp, IconColor={StaticResource PrimaryColor}}" />
       </DataTrigger>
   </Label.Triggers>
</Label>

Of course, this feature is in the banks. I know for on the user facing side, this feature looks somewhat straight forward to implement but we need to go through lots of reflection magic to implement this feature.

Of course, this is in the v4 roadmap and most probably this feature is only enough for v4 since it's a major one.

I'm consulting some friends at Maui Team and doing this feature on best possible way, therefore I'm really avoiding rushing it.

Thanks for understanding and will implement this as soon as possible.

@ricavir11
Copy link

@kezack I had the same issue and found a workarround : just add the icon name in the setter value.

Here is the workarround from your code :

<Label
         HorizontalOptions="Center"
         HorizontalTextAlignment="Center"
         Text="{mi:FontAwesomeSolid Icon=ChevronDown, IconColor={StaticResource PrimaryColor}}"                                                
         VerticalOptions="Center"
         VerticalTextAlignment="Center">
   <Label.Triggers>
       <DataTrigger
           Binding="{Binding Source={RelativeSource AncestorType={x:Type toolkit:Expander}}, Path=IsExpanded}"
           TargetType="Label"
           Value="True">
           <Setter Property="Text" Value="ChevronUp" />
       </DataTrigger>
   </Label.Triggers>
</Label>

@AathifMahir
Copy link
Owner

@kezack I had the same issue and found a workarround : just add the icon name in the setter value.

Here is the workarround from your code :

<Label
         HorizontalOptions="Center"
         HorizontalTextAlignment="Center"
         Text="{mi:FontAwesomeSolid Icon=ChevronDown, IconColor={StaticResource PrimaryColor}}"                                                
         VerticalOptions="Center"
         VerticalTextAlignment="Center">
   <Label.Triggers>
       <DataTrigger
           Binding="{Binding Source={RelativeSource AncestorType={x:Type toolkit:Expander}}, Path=IsExpanded}"
           TargetType="Label"
           Value="True">
           <Setter Property="Text" Value="ChevronUp" />
       </DataTrigger>
   </Label.Triggers>
</Label>

That's a great find but with v4 that expected release within next few weeks has official support for styles, triggers and etc..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: In Progress
Development

Successfully merging a pull request may close this issue.

5 participants