Closed flarive closed 9 months ago
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:AvaloniaApplication1.ViewModels"
xmlns:m="clr-namespace:AvaloniaApplication1.Models"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="AvaloniaApplication1.Views.MainView"
x:CompileBindings="True"
x:DataType="vm:MainViewModel">
<Design.DataContext>
<!-- This only sets the DataContext for the previewer in an IDE,
to set the actual DataContext for runtime, set the DataContext property in code (look at App.axaml.cs) -->
<vm:MainViewModel />
</Design.DataContext>
<TabControl TabStripPlacement="Top" Width="440" Height="250"
ItemsSource="{CompiledBinding TabItems}"
SelectedItem="{CompiledBinding SelectedTabItem}">
<TabControl.ItemContainerTheme>
<ControlTheme TargetType="TabItem" BasedOn="{StaticResource {x:Type TabItem}}"
x:DataType="m:CustomTabItem">
<Setter Property="Height" Value="50"/>
<Setter Property="FontSize" Value="14"/>
<Setter Property="IsEnabled" Value="{CompiledBinding Enabled}" />
<Setter Property="Header" Value="{CompiledBinding .}"/>
<Setter Property="HeaderTemplate">
<DataTemplate DataType="m:CustomTabItem">
<TextBlock Text="{CompiledBinding Header}"
TextWrapping="WrapWithOverflow"/>
</DataTemplate>
</Setter>
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate DataType="m:CustomTabItem">
<TextBlock Text="{CompiledBinding Text}"
TextWrapping="WrapWithOverflow"/>
</DataTemplate>
</Setter.Value>
</Setter>
<Setter Property="Content" Value="{CompiledBinding}"/>
</ControlTheme>
</TabControl.ItemContainerTheme>
</TabControl>
</UserControl>
@flarive can we open Q&A instead of a bug report for questions please?
Yes sure @timunie, seems that i missed something, doesn't seem to be a bug actually...
Will reopen it if it is a bug.
Thanks a lot @workgroupengineering, it works perfectly !
Hello,
I'm using Avalonia 11.0.7. I have created a TabControl with tab items coming from the view model.
View :
ViewModel :
Model :
Content is not changing when i click on tabs, why ? I have tried to play with TabControl SelectedIndex, SelectedItem, SelectedValue, SelectedValueBinding and also with TabItem IsSelected but nothing seems to work...
Could you help me please ?
Here is sample repro repo : https://github.com/flarive/AvaloniaTabControlSelectedItemNotWorking
Thank you so much for your help :)
Eviral