В настоящее время я пытаюсь реализовать функциональность tabcontrol со скрытыми вкладками, используя ListView (как вкладки) и ContentControl с привязкой к содержимому.
Я немного почитал эту тему, и если бы все было правильно, это должно было бы работать следующим образом:
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="20.0*"/>
<ColumnDefinition Width="80.0*"/>
</Grid.ColumnDefinitions>
<ListBox Grid.Column="0">
<ListBoxItem Content="Appearance"/>
</ListBox>
<ContentControl Content="{Binding SettingsPage}" Grid.Column="1"/>
</Grid>
.
.
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ContentControl x:Key="AppearancePage">
<TextBlock Text="Test" />
</ContentControl>
<ContentControl x:Key="AdvancedPage">
<TextBlock Text="Test2" />
</ContentControl>
</ResourceDictionary>
И в коде позади:
public partial class MainWindow : MetroWindow
{
private ContentControl SettingsPage;
private ResourceDictionary SettingsPagesDict = new ResourceDictionary();
public MainWindow()
{
InitializeComponent();
SettingsPagesDict.Source = new Uri("SettingsPages.xaml", UriKind.RelativeOrAbsolute);
SettingsPage = SettingsPagesDict["AppearancePage"] as ContentControl;
Несмотря на то, что он не вызывает ошибок, он не отображает "Test" TextBlock.
Скорее всего, я понял концепцию привязки неправильно, пожалуйста, дайте мне подсказку в правильном направлении.
Привет