如何将现代标签链接浮动到左侧?
how to float modern-tab links to the left?
我搜索了如何将项目的现代选项卡(布局为列表)链接浮动到左侧,不幸的是没有找到结果:/
请问大家有什么想法吗?
水平对齐被硬编码为右对齐。您需要替换控件模板:
<ControlTemplate TargetType="controls:ModernTab">
<Grid>
<!-- link list -->
<ListBox x:Name="LinkList" ItemsSource="{TemplateBinding Links}" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="{DynamicResource HeaderMargin}"
ScrollViewer.HorizontalScrollBarVisibility="Hidden"
ScrollViewer.VerticalScrollBarVisibility="Hidden"
ScrollViewer.CanContentScroll="False"
ScrollViewer.PanningMode="Both">
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
<Setter Property="FontFamily" Value="Segoe UI" />
<Setter Property="Foreground" Value="{DynamicResource MenuText}" />
<Setter Property="FontSize" Value="15"/>
<Setter Property="FontWeight" Value="Bold" />
<Setter Property="TextOptions.TextFormattingMode" Value="Ideal" />
<Setter Property="Foreground" Value="{DynamicResource MenuText}" />
<Setter Property="Margin" Value="12,0,0,0" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListBoxItem}">
<ContentPresenter x:Name="Presenter"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Foreground" Value="{DynamicResource MenuTextHover}"/>
</Trigger>
<Trigger Property="IsSelected" Value="true">
<Setter Property="Foreground" Value="{DynamicResource MenuTextSelected}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ListBox.ItemContainerStyle>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding DisplayName, Converter={StaticResource ToUpperConverter}}" />
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<!-- content -->
<controls:ModernFrame Source="{Binding SelectedSource, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}" ContentLoader="{TemplateBinding ContentLoader}" />
</Grid>
</ControlTemplate>
我知道这是一个老问题,但除了更改控件模板之外,我似乎找不到其他任何地方可以给出另一个答案。设置水平对齐对我有用:
<mui:ModernTab Layout="Tab" HorizontalAlignment="Left">
<mui:ModernTab.Links>
<!-- TODO: set @Source -->
<mui:Link DisplayName="Connect" Source="/Pages/Tab1.xaml" />
<mui:Link DisplayName="Diagnostics" Source="/Pages/Tab2.xaml" />
</mui:ModernTab.Links>
</mui:ModernTab>
我搜索了如何将项目的现代选项卡(布局为列表)链接浮动到左侧,不幸的是没有找到结果:/ 请问大家有什么想法吗?
水平对齐被硬编码为右对齐。您需要替换控件模板:
<ControlTemplate TargetType="controls:ModernTab">
<Grid>
<!-- link list -->
<ListBox x:Name="LinkList" ItemsSource="{TemplateBinding Links}" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="{DynamicResource HeaderMargin}"
ScrollViewer.HorizontalScrollBarVisibility="Hidden"
ScrollViewer.VerticalScrollBarVisibility="Hidden"
ScrollViewer.CanContentScroll="False"
ScrollViewer.PanningMode="Both">
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
<Setter Property="FontFamily" Value="Segoe UI" />
<Setter Property="Foreground" Value="{DynamicResource MenuText}" />
<Setter Property="FontSize" Value="15"/>
<Setter Property="FontWeight" Value="Bold" />
<Setter Property="TextOptions.TextFormattingMode" Value="Ideal" />
<Setter Property="Foreground" Value="{DynamicResource MenuText}" />
<Setter Property="Margin" Value="12,0,0,0" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListBoxItem}">
<ContentPresenter x:Name="Presenter"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Foreground" Value="{DynamicResource MenuTextHover}"/>
</Trigger>
<Trigger Property="IsSelected" Value="true">
<Setter Property="Foreground" Value="{DynamicResource MenuTextSelected}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ListBox.ItemContainerStyle>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding DisplayName, Converter={StaticResource ToUpperConverter}}" />
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<!-- content -->
<controls:ModernFrame Source="{Binding SelectedSource, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}" ContentLoader="{TemplateBinding ContentLoader}" />
</Grid>
</ControlTemplate>
我知道这是一个老问题,但除了更改控件模板之外,我似乎找不到其他任何地方可以给出另一个答案。设置水平对齐对我有用:
<mui:ModernTab Layout="Tab" HorizontalAlignment="Left">
<mui:ModernTab.Links>
<!-- TODO: set @Source -->
<mui:Link DisplayName="Connect" Source="/Pages/Tab1.xaml" />
<mui:Link DisplayName="Diagnostics" Source="/Pages/Tab2.xaml" />
</mui:ModernTab.Links>
</mui:ModernTab>