Comments (2)
Don't store control instances in your ViewModels. Use the HeaderTemplate
and ContentTemplate
to control the view from a ViewModel:
<ui:TabView IsAddTabButtonVisible="False"
TabCloseRequested="TabView_TabCloseRequested"
CanDragTabs="True" CanReorderTabs="True"
TabItems="{Binding TabView}"
SelectedItem="{Binding SelectedTab}">
<ui:TabView.TabItemTemplate>
<DataTemplate DataType="local:TabItem">
<ui:TabViewItem IconSource="{Binding IconSource}"
Header="{Binding }"
Content="{Binding }">
<ui:TabViewItem.HeaderTemplate>
<DataTemplate DataType="local:TabItem">
<controls:MyCustomHeader />
</DataTemplate>
</ui:TabViewItem.HeaderTemplate>
<ui:TabViewItem.ContentTemplate>
<DataTemplate DataType="local:TabItem">
<controls:MyCustomContent />
</DataTemplate>
</ui:TabViewItem.ContentTemplate>
</ui:TabViewItem>
</DataTemplate>
</ui:TabView.TabItemTemplate>
</ui:TabView>
If you need more control over specific control views for each tab, then you need to wrap your headers and content ViewModels in their own classes and create DataTemplates for each. Read up and familiarize yourself with how MVVM works:
public class TabItemViewModel
{
public TabItemHeaderBase Header { get; }
public TabItemContentBase Content { get; }
}
// Base classes for TabItem headers and contents - derived classes can add extra functionality
public class TabItemHeaderBase
{
}
public class TabItemContentBase
{
}
Create DataTemplates to support each of these:
<Window.DataTemplates>
<DataTemplate DataType="vm:TabItemHeader1">
....
</DataTemplate>
...
</Window.DataTemplates>
Then just adjust your TabView like:
<ui:TabView IsAddTabButtonVisible="False"
TabCloseRequested="TabView_TabCloseRequested"
CanDragTabs="True" CanReorderTabs="True"
TabItems="{Binding TabView}"
SelectedItem="{Binding SelectedTab}">
<ui:TabView.TabItemTemplate>
<DataTemplate DataType="local:TabItem">
<ui:TabViewItem IconSource="{Binding IconSource}"
Header="{Binding Header}"
Content="{Binding Content}">
</ui:TabViewItem>
</DataTemplate>
</ui:TabView.TabItemTemplate>
</ui:TabView>
from fluentavalonia.
Ahhh, yes I understand. I see now that my question was pretty stupid 😥 Thanks for taking the time to provide such a detailed response.
from fluentavalonia.
Related Issues (20)
- AppWindow WindowState disappears from taskbar HOT 3
- NullReferenceException when clicking FAIconElement/IconSource - Symbol Enum in FAControlsGallery
- Blank space appears when scrolling up in ListView with variable sized elements HOT 1
- Transparent ToggleButton styles will not work
- GridView control implementation
- NavigationView selection indictor doesn't always show
- Window moves up the screen when resizing. HOT 1
- NullReferenceException is thrown when using FACombBox with Flyout HOT 2
- ContentDialog buttons not showing HOT 1
- NullReferenceException when trying to remove selected item in NavigationView 2.1.0-preview6
- TextBox flyout commands and SelectableTextBox command buttons not working
- SettingsExpander is swallowing space key HOT 2
- Can I disable Escape key of ContentDialog?
- FluentAvolonia OpenFolderPicker cannot return to the previous directory
- Unable to find OverlayLayer from given TopLevel HOT 1
- Disabled colour the DataGrid uses when dark themed looks wrong.
- AppWindow icon appears edgy on the Windows taskbar
- Shadows are missing in FluentAvalonia 2.1.0 HOT 1
- NavigationView selection indicator animation has problems HOT 1
- Right button menu not functional at text
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fluentavalonia.