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

Tiny TabControl addition. #280

Merged
merged 2 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions SukiUI.Demo/Common/ViewLocator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@ public class ViewLocator : IDataTemplate

public Control Build(object? data)
{
var fullName = data?.GetType().FullName;
if (fullName is null)
{
return new TextBlock { Text = "Data is null or has no name." };
}
if(data is null)
return new TextBlock { Text = "Data is null." };

var fullName = data.GetType().FullName;

if (string.IsNullOrWhiteSpace(fullName))
return new TextBlock { Text = "Type has no name, or name is empty." };

var name = fullName.Replace("ViewModel", "View");
var type = Type.GetType(name);
if (type is null)
{
return new TextBlock { Text = $"No View For {name}." };
}

if (!_controlCache.TryGetValue(data!, out var res))
if (!_controlCache.TryGetValue(data, out var res))
{
res ??= (Control)Activator.CreateInstance(type)!;
_controlCache[data!] = res;
_controlCache[data] = res;
}

res.DataContext = data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@
<TabControl TabStripPlacement="Bottom" />
</suki:GroupBox>
</suki:GlassCard>
<suki:GlassCard>
<suki:GroupBox Header="Horizontal Left Tab Control">
<TabControl Classes="HorizontalTabs" TabStripPlacement="Left" />
</suki:GroupBox>
</suki:GlassCard>
<suki:GlassCard>
<suki:GroupBox Header="Horizontal Right Tab Control">
<TabControl Classes="HorizontalTabs" TabStripPlacement="Right" />
</suki:GroupBox>
</suki:GlassCard>
</WrapPanel>
</ScrollViewer>
</Grid>
Expand Down
19 changes: 18 additions & 1 deletion SukiUI/Theme/TabControl.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

<Style Selector="^[TabStripPlacement=Left] /template/ LayoutTransformControl#PART_LayoutTransform">
<Setter Property="LayoutTransform" Value="rotate(-90deg)" />
<Style Selector="^ ItemsPresenter#PART_ItemsPresenter &gt; WrapPanel">
<Style Selector="^ ItemsPresenter#PART_ItemsPresenter WrapPanel">
<Setter Property="Orientation" Value="Horizontal" />
<Setter Property="FlowDirection" Value="RightToLeft" />
</Style>
Expand All @@ -42,7 +42,24 @@
<Style Selector="^[TabStripPlacement=Top] /template/ ItemsPresenter#PART_ItemsPresenter">
<Setter Property="Margin" Value="{DynamicResource TabControlTopPlacementItemMargin}" />
</Style>

<Style Selector="^.HorizontalTabs">
<Style Selector="^[TabStripPlacement=Left] /template/ LayoutTransformControl#PART_LayoutTransform">
<Setter Property="LayoutTransform" Value="rotate(0)" />
<Style Selector="^ ItemsPresenter#PART_ItemsPresenter WrapPanel">
<Setter Property="Orientation" Value="Vertical" />
<Setter Property="FlowDirection" Value="RightToLeft" />
</Style>
</Style>
<Style Selector="^[TabStripPlacement=Right] /template/ LayoutTransformControl#PART_LayoutTransform">
<Setter Property="LayoutTransform" Value="rotate(0)" />
<Style Selector="^ ItemsPresenter#PART_ItemsPresenter WrapPanel">
<Setter Property="Orientation" Value="Vertical" />
</Style>
</Style>
</Style>
</ControlTheme>

<ControlTheme x:Key="{x:Type TabControl}"
BasedOn="{StaticResource SukiTabControlStyle}"
TargetType="TabControl" />
Expand Down