Closed MartinZikmund closed 4 weeks ago
When fixed, revert Uno specific TODOs in both TabView.xaml
files
Strange that TabView
is using this - I was under the impression it wasn't supported on UWP? https://stackoverflow.com/questions/33573929/uwp-binding-in-style-setter-not-working
Stack OverflowI have problem with creating xaml control. I'm writing new project in VS 2015 in universal app. I want create grid. In this grid I want to have a button. In model I specifi the column (Level) and R...
@davidjohnoliver They are using it this way:
<contract7Present:Setter Property="CornerRadius" Value="{Binding Source={ThemeResource OverlayCornerRadius}, Converter={StaticResource TopCornerRadiusFilterConverter}}"/>
So maybe this use-case is supported - to utilize {Binding}
for the purposes of a value converter applied on a resource
Ahhhh...... yeah, maybe it works in the particular case that a Source is specified (and it's a resource)
We'll probably have to make a special case for those. it's probably excluded explicitly in the generator for setters.
This probably could be supported using SetterExtensions.ApplyThemeResourceUpdateValues()
, similar to as is done when the value is directly set to a ThemeResource:
Ensure the fix also supports the following scenario:
Given VS 2019, create new UNO solution, leave only 3 projects: Shared, UWP and Wasm Add some value converter:
public class SomeConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
return (parameter ?? "").ToString();
}
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new NotImplementedException();
}
}
Use it in MainPage.xaml:
<Page
x:Class="SetterConvertedBug.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:SetterConvertedBug"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Page.Resources>
<local:SomeConverter x:Key="SomeConverter"/>
</Page.Resources>
<Grid>
<TextBlock>
<TextBlock.Resources>
<Style TargetType="TextBlock">
<Setter Property="Text">
<Setter.Value>
<Binding Path="Whatever" Converter="{StaticResource SomeConverter}"/>
</Setter.Value>
</Setter>
</Style>
</TextBlock.Resources>
</TextBlock>
</Grid>
</Page>
Build. UWP build is OK, Wasm build fails with error at Uno.UI.SourceGenerators.XamlGenerator.XamlFileGenerator.BuildBindingOption(XamlMemberDefinition m, INamedTypeSymbol propertyType) в C:\a\1\s\src\SourceGenerators\Uno.UI.SourceGenerators\XamlGenerator\XamlFileGenerator.cs:line 5023
The same happens for inline binding declaration like
<Setter Property="Text" Value="{Binding Path=Whatever, Converter={StaticResource SomeConverter}}"/>
with and without converter parameter.
Possible fixed with https://github.com/unoplatform/uno/pull/16010 ? Not sure
Possible fixed with #16010 ? Not sure
@MartinZikmund, maybe @morning4coffe-dev can help validate if it is already fixed or not
@MartinZikmund, @agneszitte, Tested on Skia, wasm, and Android with Uno 5.3.0-dev.1282
- all platforms now have the same behavior as WinUI for both scenarios. For the first one, I can see a red ‘Test’ text, and for the second one, although I see a blank page, it is the same behavior for me as on WinUI and it no longer results in any error.
Current behavior
When
Binding
is used inStyle
Setter
, Uno targets don't compile.Expected behavior
Should compile.
TabView
button style uses this approach, so it would be a useful addition.How to reproduce it (as minimally and precisely as possible)
Run the app on Windows and notice the text is red.
Try to compile under Uno and notice build fails with error CS1024: Preprocessor directive expected
The error is also in the generated
g.cs
file, similar to the following:Workaround
Avoid use of Binding in style setter
Environment
Nuget Package:
Nuget Package Version(s):
Affected platform(s):
IDE:
Relevant plugins:
Anything else we need to know?