Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
kikipoulet committed Aug 26, 2024
2 parents af7ec0a + 2757bb7 commit 1016556
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 10 deletions.
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

0 comments on commit 1016556

Please sign in to comment.