-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
[Windows] [RC2] Conditional ToolbarItem Text Display Using OnIdiom Not Working in Release Mode #18697
Comments
@StephaneDelcroix Thoughts? |
one path is using SetValue, the other is using SetBinding... I would not have considered this as a bug and only a possible enhancement, but the mismatch between debug and release require a solution |
Is there any workaround that we can use at the moment ? |
@StephaneDelcroix If there's any workaround for this issue please let me know, we are deploying our app on December. |
@malsabi i have it working like this in case you don't need anything from the binding Just return the string value and it will work in both debug/release |
@cgomezm namespace ToolBarItemIssue.Common.Extensions
{
[ContentProperty(nameof(Name))]
public class TranslateExtension : IMarkupExtension<BindingBase>
{
public string? Name { get; set; }
public BindingBase ProvideValue(IServiceProvider serviceProvider)
{
throw new NotImplementedException();
}
object IMarkupExtension.ProvideValue(IServiceProvider serviceProvider)
{
if (string.IsNullOrEmpty(Name))
return "N/A";
return LocalizationResourceManager.Instance[Name];
}
}
} |
@malsabi I moved away from returning the binding and just return the string value.
|
@cgomezm if (AppResources.Culture.TwoLetterISOLanguageName.Equals("en"))
{
LocalizationResourceManager.Instance.SetCulture(new CultureInfo("ar"));
}
else
{
LocalizationResourceManager.Instance.SetCulture(new CultureInfo("en"));
} |
@malsabi yeah, that could be a downside as is the value being returned instead of the binding. Maybe dotnet team has made some progress on their investigation of this. |
@jsuarezruiz any thoughts or progress about this issue ? |
Can repro this issue at Windows platform on the latest 17.10.0 Preview 3(8.0.7&8.0.20). |
Compile OnIdiom markup extension. Doing that we can infer the type of the ProvidedValue instead of using Object - fixes #18697
Compile OnIdiom markup extension. Doing that we can infer the type of the ProvidedValue instead of using Object - fixes #18697
We can not fix this, in either way: it's not possible (using a reasonable effort) to make it succeed (in all cases) when XamlC is on, and it's not possible to have it fail when XamlC is off one way would be to deprecate OnIdiom in favour of OnIdiom (oh, well, it used to be that way) |
found a solution, finally |
Can you tell us what was the solution ? Is there any changes we need to know about ? |
Description
When I use
Text="{ext:Translate ProfileToolBarText}"
withoutOnIdiom
, it works correctly in both Release and Debug modes. However, I intend to display the text on Desktop only, but this setup only works in Debug mode. In Release mode, it incorrectly displaysMicrosoft.Maui.Controls.Binding
Behavior in Release Mode (incorrect)
Behavior in Debug Mode (expected):
No exceptions are evident in the output that could indicate the root cause. The issue seems to arise when using OnIdiom.
Steps to Reproduce
Microsoft.Maui.Controls.Binding
.Link to public reproduction project repository
https://github.com/malsabi/ToolBarItemIssue
Version with bug
8.0.0-rc.2.9511
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
Windows
Affected platform versions
Windows10.0.19041.0
Did you find any workaround?
No I didn't find any workaround.
Relevant log output
No response
The text was updated successfully, but these errors were encountered: