-
Note: I know I may not get a good impression when I mention that I am an MVVM fan, I just want to say that I am not that pure MVVM developer either, and I am willing to embrace every solution that can improve development efficiency and elegant coding. Hi, thank you for making this great theme. I would like to know what is the best way to use I tried to create an In ViewModel.cs: public class VMTabViewPage: ViewModelBase
{
[Reactive] public string Title { get; set; } = "New Chat";
}
public class MainWindowViewModel : ViewModelBase
{
[Reactive] ObservableCollection<VMTabViewPage> VMTabViewPages { get; set; } = new();
public void AddTabViewPage()
{
VMTabViewPages.Add(new VMTabViewPage());
}
} In View.axaml: <ui:TabView TabItems="{Binding VMTabViewPages}" AddTabButtonCommand="{Binding AddTabViewPage}">
<ui:TabView.TabItemTemplate>
<DataTemplate x:DataType="vm:VMTabViewPage">
<ui:TabViewItem Header="{Binding Title}"/>
</DataTemplate>
</ui:TabView.TabItemTemplate>
</ui:TabView> So I get a nested TabVie Through this phenomenon, it can be found that by changing the Also, I will not be able to bind I have looked at the sample code of other projects, and among them there is a If you @amwx , as the author, have a completely different understanding of how The information I've provided may not be comprehensive, so if you need more information, please let me know and I'll provide it as soon as possible. Sorry I don't have a repo available for reference, this is because I haven't protected the OpenAI API Key in it. Thank you very much for reading this, even if you may not be able to help :) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Unfortunately, a side effect of the new ItemsControl design upstream meant that I can't create Instead, what I'm suggesting as an interim solution is to using the styling system to set the properties you need, which is similar to what you'd do in WPF. <Style Selector="ui|TabViewItem">
<Setter Property="Header" Value="{Binding DataHeader}" />
...
</DataTemplate> |
Beta Was this translation helpful? Give feedback.
Unfortunately, a side effect of the new ItemsControl design upstream meant that I can't create
TabViewItem
s from the ItemTemplate property anymore (since container creation is handled outside of my logic). I think there is some work that might make this possible again that's open upstream, so I'll re-evaluate after that's complete. This means you can't set a TabViewItem as the ItemTemplate as in WinUI, as it just ends up getting put into a generated TabViewItem.Instead, what I'm suggesting as an interim solution is to using the styling system to set the properties you need, which is similar to what you'd do in WPF.