You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I bind ItemsSource in TabView my controls (placed in TabView.ItemTemplate) are changed over all TabItems. It seems that the same Control is shared over all TabItems
Expected behavior
Every TabItem holds its own control instances of the ItemTemplate content
Minimal reproduction of the problem with instructions
I've attached a sample UWP app. This contains the following code:
-TabView
-TabView.ItemTemplate
-A custom control (changes background color to red, if text is empty on LostFocus event or turns green if a value is set)
Hi @oliverluethi, this is how the WPF TabControl behaves which is how the TabView was designed to behave as well in order to re-use controls for data type forms as a form of virtualization via data binding. Linking to the WinUI Issue as well for tracking.
In order to use the control in your desired pattern, you just need to use the TabView for your Tab header pieces and an ItemsControl for the content frame to remember state. E.g.
I'm submitting a Bug report
Current behavior
When I bind ItemsSource in TabView my controls (placed in TabView.ItemTemplate) are changed over all TabItems. It seems that the same Control is shared over all TabItems
Expected behavior
Every TabItem holds its own control instances of the ItemTemplate content
Minimal reproduction of the problem with instructions
I've attached a sample UWP app. This contains the following code:
-TabView
-TabView.ItemTemplate
-A custom control (changes background color to red, if text is empty on LostFocus event or turns green if a value is set)
MainPage.xaml
<my:TabView x:Name="Test" Height="500" Width="600" TabNavigation="Cycle"> <my:TabView.ItemTemplate> <DataTemplate> <local:MyControl Style="{StaticResource Test}" Text="" /> </DataTemplate> </my:TabView.ItemTemplate> </my:TabView>
Custom Control
`public class MyControl : TextBox
{
private Border _border;
UWPTestApp.zip
Environment
Nuget Package(s):
Microsoft.Toolkit.Uwp
Microsoft.Toolkit.Uwp.UI.Controls
Package Version(s):
5.1.1
Windows 10 Build Number:
App min and target version:
Device form factor:
Visual Studio
The text was updated successfully, but these errors were encountered: