I have looked at most resources but i can find a good solution. I have a tab control HARD coded.
<TabControl TabStripPlacement="Left" Padding="0" Style="{DynamicResource SettingsTab}" ItemContainerStyle="{DynamicResource SettingsTabItemStyle}" Background="WhiteSmoke" >
<TabItem Header="ΓΕΝΙΚΑ" Margin="0" IsEnabled="False" > <Grid /></TabItem>
<TabItem Header="Προσωπικό" Margin="0" IsSelected="True">
<Grid MinHeight="400">
<ContentControl HorizontalAlignment="Stretch" Margin="50,67,50,0" Name="ActiveItem" />
</Grid>
</TabItem>
<TabItem Header="Τραπέζια" Margin="0">
<Grid />
</TabItem>
UPDATE - Restate problem
Here is my customized tab control. The gray text is a disabled tab item it acts like a group. Like General settings, System settings etc. So it has a role as a navigation menu. Curently i have a content control at each tabitem (not the disabled ones) and bind the view model i want.
But i cant use Conductor.Collection.OneActive with CM.
Why?
I have seen helloscreens example from CM sample and other samples but the problem here is that if i do this via binding then there is no way to display the disabled tabitems other than creating a dummy view model that serves no purpose.So how can i achieve this ?
Update: source here
I have a tab control HARD coded.
Is this a requirement?
But i cant use Conductor.Collection.OneActive with CM. Why?
I think the reason this won't work is to use Conductor.Collection.OneActive
you need to bind the ItemsSource
to the Items collection. If you're going to bind ItemsSource
you can't also describe the tab items in XAML
.
I created a solution that doesn't involve describing the tab items in xaml.
The key parts:
In ShellView
the TabControl
ItemContainerStyle
is described to the tab items IsEnabled
property can be bound to the view model.
<TabControl x:Name="Items"
Grid.Row="1"
TabStripPlacement="Left">
<TabControl.ItemContainerStyle>
<Style TargetType="{x:Type TabItem}">
<Setter Property="IsEnabled" Value="{Binding IsEnabled}"/>
</Style>
</TabControl.ItemContainerStyle>
</TabControl>
ShellViewModel is similar but we're now activating the second view model because the first one is not enabled.
public class HeaderViewModel : BaseTabViewModel
{
public HeaderViewModel(string name)
{
DisplayName = name;
IsEnabled = false;
}
}
public ShellViewModel(Tab2ViewModel tab2ViewModel,
Tab3ViewModel tab3ViewModel
)
{
Items.Add (new HeaderViewModel ("ΓΕΝΙΚΑ"));
Items.Add(tab2ViewModel);
Items.Add(tab3ViewModel);
ActivateItem (tab2ViewModel);
}
Enable or disable the tab item in the constructor of the view model.
public Tab2ViewModel()
{
DisplayName = "Προσωπικό";
IsEnabled = true;
}
The un-styled result is that the first tab item is disabled and the next two are enabled.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With