Open eriklimakc opened 9 months ago
winappsdk and sttached property..:
<Setter Property="um:ControlExtensions.TrailingIcon" Value="{x:Null}" />
<Setter Property="local:ControlHelper.Asd" Value="Qwe" />
<Setter Property="local:ControlHelper.AsdIcon" Value="{x:Null}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="TextBox">
<StackPanel x:Name="Root">
<void:Border Tag="X" void:Visibility="{Binding Path=(um:ControlExtensions.TrailingIcon), RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource MaterialNullToCollapsedConverter}, FallbackValue=Collapsed, TargetNullValue=Collapsed}">
<Button Content="{Binding Path=(um:ControlExtensions.TrailingIcon), RelativeSource={RelativeSource TemplatedParent}}"
void:Command="{Binding Path=(um:ControlExtensions.TrailingCommand), RelativeSource={RelativeSource TemplatedParent}}"
void:Visibility="{Binding Path=(um:ControlExtensions.IsTrailingIconVisible), RelativeSource={RelativeSource TemplatedParent}}"/>
</void:Border>
<void:ContentControl Tag="O" Content="{TemplateBinding um:ControlExtensions.TrailingIcon}" />
<void:ContentControl Tag="X" Content="{Binding Path=(um:ControlExtensions.TrailingIcon), RelativeSource={RelativeSource TemplatedParent}}" />
<void:ContentControl Tag="X" Content="{Binding Path=(um:ControlExtensions.TrailingIcon), RelativeSource={RelativeSource Mode=TemplatedParent}}" />
<ContentControl Tag="O" Content="{TemplateBinding local:ControlHelper.Asd}" />
<ContentControl Tag="O" Content="{Binding Path=(local:ControlHelper.Asd), RelativeSource={RelativeSource TemplatedParent}}" />
<ContentControl Tag="O" Content="{Binding Path=(local:ControlHelper.Asd), RelativeSource={RelativeSource Mode=TemplatedParent}}" />
<!-- note: both work, just not both at same time (since UIElement can nested under 1 parent at a time) -->
<!--<ContentControl Tag="O" Content="{TemplateBinding local:ControlHelper.AsdIcon}" />-->
<!--<ContentControl Tag="O" Content="{Binding Path=(local:ControlHelper.AsdIcon), RelativeSource={RelativeSource TemplatedParent}}" />-->
<Button Tag="O" Content="{TemplateBinding um:ControlExtensions.TrailingIcon}" />
<void:Button Tag="X" Content="{Binding Path=(um:ControlExtensions.TrailingIcon), RelativeSource={RelativeSource TemplatedParent}}" />
^ for attached properties from local assemblies, binding and template-binding all work. ^ for attached properties from foreign assemblies, binding doesnt work, but template-binding works. __^ note: we can't use template binding with converter... so it is not a valid workaround.
good ole microsoft/microsoft-ui-xaml#6388 ^ we did tried to use Jerome's workaround with default {x:Null}, which doesnt work... ^ we also tried to use this other workaround from toolkit, which also doesnt work..: https://github.com/unoplatform/uno.toolkit.ui/blob/main/samples/Uno.Toolkit.Samples/Uno.Toolkit.Samples.Shared/Content/Controls/DrawerFlyoutSamplePage.xaml#L25
@jeromelaban given the disparity between attached dp defined locally and from package, could we have failed to generate/missed copying certain files in the package that winappsdk needs?
Run the WinUI app using the native debugger, it may give you more information about the issue (make sure to be on 1.4 latest)
I got the following , but I guess this doesn't offer much context:
cc @jeromelaban @Xiaoy312
You'll need to look at the output window to get meaningful information.
Microsoft.ui.xaml.dll!00007FFB78FF8841: 80004005 - Unspecified error
Microsoft.ui.xaml.dll!00007FFB78F9EFB0: 80004005 - Unspecified error
Exception thrown at 0x00007FFC9F96565C (KernelBase.dll) in LeadingIcon.Windows.exe: WinRT originate error - 0x80004005 : 'System.Runtime.InteropServices.COMException'.
Microsoft.ui.xaml.dll!00007FFB78FC512F: 80004005 - Unspecified error
These are the last logs from the output before the app crashes. I couldn't find any relevant information from the output, but I am attaching it here so you guys can take a look.
@Xiaoy312 @jeromelaban
HResult = -2147467259 (0x80004005) // E_FAIL element measured at frame 99 or 00 is MainPage exception.Data:
[Description] = No such interface supported
[RestrictedDescription] = No such interface supported
[RestrictedErrorReference] =
[RestrictedCapabilitySid] =
[__RestrictedErrorObjectReference] = WinRT.ExceptionHelpers+__RestrictedErrorObject
[__HasRestrictedLanguageErrorObject] = False
@jeromelaban I don't see anything helpful in the stacktrace unless you see something?
I'll take a look
@Youssef1313 , here's a repro with the style/template that may facilitate the investigation... The style/template is basically a copy of the MaterialOutlinedTextBoxStyle defined in my branch (dev/ERLI/TextBox-Icons).
cc @kazo0
I got nowhere investigating this 😕
based on my previous research: https://github.com/unoplatform/Uno.Themes/issues/1286#issuecomment-1826145345
just as a workaround:
we can probably just stick to {TemplateBinding}, and use a custom control that takes either an IconElement
or an CustomIcon
(name to be discussed) that is a DependencyObject
with properties like (Icon, IsVisible, Command,...).
This way we can bypass the types of binding that would fail on WinAppSdk and use TemplateBinding on control's local depenncy-property for {icon,visibility,command}.
CustomIconPresenter.Icon.changed += (s, e) => {
var sender = s as CustomIconPresenter ?? throw ...;
// todo: clear previous values
if (e.NewValue is CustomIcon custom) {
sender.SetBinding(CustomIconPresenter.IconElementProperty, new Binding(nameof(CustomIcon.Icon)) { RelativeSource=TemplatedParent });
// todo: same for IsVisible and Command...
else if (e.NewValue is IconElement) {
sender.IconElement = icon;
Current behavior
Windows (WinUI) specific.
When setting LeadingIcon to TextBox the error "Failed to assign LeadingIcon" occurs.
Obs.: And even if LeadingIcon is not set an unhandled excpetion is thrown.
How to reproduce it (as minimally and precisely as possible)
Environment
Nuget Package:
Package Version(s):
Affected platform(s):
Anything else we need to know?