Closed kotturtech closed 2 years ago
After some search for a workaround, I have come up with the following solution:
To make the TemplateSelector work on Android, I've created the TemplateSelector as a static resource, and assigned it in the style of the FlipViewItem, as follows (Omitting some irrelevant specifics):
<xamarin:FlipView ItemsSource="{Binding Pages}" SelectedItem="{Binding SelectedPage,Mode=TwoWay}">
<xamarin:FlipView.Resources>
<infraUI:ViewSelector x:Key="ViewSelector">
<!-- This is my TemplateSelector-->
</infraUI:ViewSelector>
<Style TargetType="FlipViewItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="FlipViewItem">
<ContentPresenter Content="{TemplateBinding Content}" ContentTemplateSelector="{StaticResource ViewSelector}">
</ContentPresenter>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</xamarin:FlipView.Resources>
</xamarin:FlipView>
However, this approach won't work properly on UWP. Therefore, I have resorted to platform-specific xaml and implemented the view separately for UWP and for other platforms. My solution for UWP is simply assigning the TemplateSelector to FlipView.ItemTemplateSelector property.
I have same problem but in WASM project and in relation to ListView
I have this issue too. I tried with uno.ui 3.8, 3.11 and 4.4. The version 3.X are working fine, version 4.4 seems to be working fine, but I saw #8637. The only way I was able to reproduce this was to add Uno.Material to my project
Current behavior
In the following controls: FlipView, Pivot: When setting the ItemTemplateSelector property (Using custom template selector), data templates are still not being applied on items. Instead, a string with the type name of the item (ViewModel) appears. This issue reproduces for me on Android platform only, whereas on UWP platform everything works fine
This issue seems to be akin to the following previous issue: https://github.com/unoplatform/uno/issues/491
Expected behavior
Data tempates generated by the Template Selector should be applied to items according to the logic of the specified DataTemplateSelector
How to reproduce it (as minimally and precisely as possible)
The following example demonstrates the issue. I have used a FlipView in my example, however the issue similarly reproduces with the Pivot control as well.
Code:
XAML:
Workaround
Since this issue is akin to issue 491, I will try a similar workaround in my case as well. Currently can't confirm that it works though
Environment
Nuget Package:
Nuget Package Version(s):
Affected platform(s):
IDE:
Relevant plugins:
Anything else we need to know?