Skip to content

Commit

Permalink
Example code for StackPanel
Browse files Browse the repository at this point in the history
  • Loading branch information
NotYoojun committed Jan 3, 2025
1 parent b1a7507 commit 14eb769
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ikw="http://schemas.inkore.net/lib/ui/wpf"
xmlns:sc="clr-namespace:SamplesCommon;assembly=SamplesCommon"
xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern"
mc:Ignorable="d">
xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern"
xmlns:local="clr-namespace:iNKORE.UI.WPF.Modern.Gallery"
mc:Ignorable="d" Loaded="Page_Loaded" d:DesignWidth="1158">
<ScrollViewer>
<ikw:SimpleStackPanel Style="{StaticResource ControlPageContentPanelStyle}">
<sc:ControlExample x:Name="Example1" HeaderText="A SimpleStackPanel control.">
<local:ControlExample x:Name="Example1" HeaderText="A SimpleStackPanel control.">

<ikw:SimpleStackPanel
x:Name="Control1"
VerticalAlignment="Top"
Orientation="Vertical">
<ikw:SimpleStackPanel x:Name="Control1" Spacing="0"
VerticalAlignment="Top" Orientation="Vertical" HorizontalAlignment="Left">
<ikw:SimpleStackPanel.Resources>
<Style TargetType="Rectangle">
<Setter Property="Height" Value="40" />
Expand All @@ -28,18 +27,21 @@
<Rectangle Fill="Yellow" />
</ikw:SimpleStackPanel>

<sc:ControlExample.Options>
<local:ControlExample.Options>
<ikw:SimpleStackPanel Style="{StaticResource OptionsPanelStyle}">
<ui:RadioButtons ItemsSource="{Binding Source={x:Type Orientation}, Converter={StaticResource EnumValuesConverter}}" SelectedItem="{Binding ElementName=Control1, Path=Orientation}" />
<ui:NumberBox
Header="Spacing"
Minimum="0"
<ui:RadioButtons x:Name="RadioButtons_Orientation"
ItemsSource="{Binding Source={x:Type Orientation}, Converter={StaticResource EnumValuesConverter}}"
SelectedItem="{Binding ElementName=Control1, Path=Orientation}"
SelectionChanged="RadioButtons_Orientation_SelectionChanged"/>
<ui:NumberBox x:Name="NumberBox_Spacing"
Header="Spacing" Minimum="0"
SpinButtonPlacementMode="Inline"
Value="{Binding ElementName=Control1, Path=Spacing}" />
Value="{Binding ElementName=Control1, Path=Spacing}"
ValueChanged="NumberBox_Spacing_ValueChanged"/>
</ikw:SimpleStackPanel>
</sc:ControlExample.Options>
</local:ControlExample.Options>

</sc:ControlExample>
</local:ControlExample>
</ikw:SimpleStackPanel>
</ScrollViewer>
</ui:Page>
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System.Windows.Controls;
using System.Windows;
using System.Windows.Controls;
using iNKORE.UI.WPF.Modern.Controls;

namespace iNKORE.UI.WPF.Modern.Gallery.Pages.Controls.Windows
{
Expand All @@ -9,14 +11,49 @@ public StackPanelPage()
InitializeComponent();
}

private void Page_Loaded(object sender, RoutedEventArgs e)
{
UpdateExampleCode();
}


private void NumberBox_Spacing_ValueChanged(NumberBox sender, NumberBoxValueChangedEventArgs args)
{
UpdateExampleCode();
}

private void RadioButtons_Orientation_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
UpdateExampleCode();
}


#region Example Code

public void UpdateExampleCode()
{
if (!this.IsLoaded) return;

Example1.Xaml = Example1Xaml;
}

#endregion

public string Example1Xaml => $@"
<ikw:SimpleStackPanel x:Name=""Control1""
Orientation=""{RadioButtons_Orientation.SelectedItem}"" Spacing=""{NumberBox_Spacing.Value}"">
<ikw:SimpleStackPanel.Resources>
<Style TargetType=""Rectangle"">
<Setter Property=""Height"" Value=""40"" />
<Setter Property=""Width"" Value=""40"" />
</Style>
</ikw:SimpleStackPanel.Resources>
<Rectangle Fill=""Red"" />
<Rectangle Fill=""Blue"" />
<Rectangle Fill=""Green"" />
<Rectangle Fill=""Yellow"" />
</ikw:SimpleStackPanel>
";

#endregion
}
}

0 comments on commit 14eb769

Please sign in to comment.