Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code behind #24

Open
marcosgerene opened this issue Dec 30, 2024 · 1 comment
Open

Code behind #24

marcosgerene opened this issue Dec 30, 2024 · 1 comment

Comments

@marcosgerene
Copy link

Hi @egorozh

How to work with it using codebehind, without any viewmodel?

@marcosgerene
Copy link
Author

I have already found it:

   // Create the content for the tab
   var contentView = new TextBlock
   {
       Text = "This is a dynamically added view.",
       HorizontalAlignment = Avalonia.Layout.HorizontalAlignment.Center,
       VerticalAlignment = Avalonia.Layout.VerticalAlignment.Center
   };

   // Create a new TabItem
   var newTabItem = new DragTabItem
   {
       Header = "New Tab", // Set tab header
       Content = contentView // Set tab content
   };

   // Add the tab to the TabablzControl
   TabPrincipal.Items.Add(newTabItem);

   // Optionally select the newly added tab
   TabPrincipal.SelectedItem = newTabItem;

But now the close button does not work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant