Skip to content

Commit

Permalink
added dynamic fylout to demo
Browse files Browse the repository at this point in the history
  • Loading branch information
thoemmi committed Oct 30, 2014
1 parent 771e6c4 commit 1a88a84
Show file tree
Hide file tree
Showing 6 changed files with 126 additions and 2 deletions.
57 changes: 57 additions & 0 deletions samples/MetroDemo/ExampleWindows/DynamicFlyout.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<Controls:Flyout x:Class="MetroDemo.ExampleWindows.DynamicFlyout"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:Controls="http://metro.mahapps.com/winfx/xaml/controls"
mc:Ignorable="d"
Header="Dynamic Flyout"
d:DesignHeight="300" d:DesignWidth="300">
<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<StackPanel>
<TextBlock Grid.Row="0"
Text="Something above the ScrollPanel" />
<TextBlock Grid.Row="0"
Text="This Flyout animates its opacity when opening and closing."/>
</StackPanel>
<ScrollViewer Grid.Row="1"
VerticalScrollBarVisibility="Auto">
<StackPanel Orientation="Vertical">
<TextBox x:Name="firstTB" Controls:TextboxHelper.Watermark="TextBox 01" />
<TextBox Margin="0,5,0,0"
Controls:TextboxHelper.Watermark="TextBox 02" />
<TextBox Margin="0,5,0,0"
Controls:TextboxHelper.Watermark="TextBox 03" />
<TextBox Margin="0,5,0,0"
Controls:TextboxHelper.Watermark="TextBox 04" />
<TextBox Margin="0,5,0,0"
Controls:TextboxHelper.Watermark="TextBox 05" />
<TextBox Margin="0,5,0,0"
Controls:TextboxHelper.Watermark="TextBox 06" />
<TextBox Margin="0,5,0,0"
Controls:TextboxHelper.Watermark="TextBox 07" />
<TextBox Margin="0,5,0,0"
Controls:TextboxHelper.Watermark="TextBox 08" />
<TextBox Margin="0,5,0,0"
Controls:TextboxHelper.Watermark="TextBox 09" />
<TextBox Margin="0,5,0,0"
Controls:TextboxHelper.Watermark="TextBox 10" />
</StackPanel>
</ScrollViewer>
<UniformGrid Columns="2"
Grid.Row="2"
Margin="10">
<Button Style="{DynamicResource SquareButtonStyle}"
Margin="10"
Content="Create" />
<Button Style="{DynamicResource SquareButtonStyle}"
Margin="10"
Content="Cancel" />
</UniformGrid>
</Grid>
</Controls:Flyout>
24 changes: 24 additions & 0 deletions samples/MetroDemo/ExampleWindows/DynamicFlyout.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace MetroDemo.ExampleWindows {
/// <summary>
/// Interaction logic for DynamicFlyout.xaml
/// </summary>
public partial class DynamicFlyout {
public DynamicFlyout() {
InitializeComponent();
}
}
}
6 changes: 5 additions & 1 deletion samples/MetroDemo/ExampleWindows/FlyoutDemo.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
</Controls:MetroWindow.RightWindowCommands>

<Controls:MetroWindow.Flyouts>
<Controls:FlyoutsControl>
<Controls:FlyoutsControl x:Name="flyoutsControl">
<Controls:Flyout x:Name="settingsFlyout"
Margin="100 0 0 0"
Width="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=Controls:MetroWindow}, Path=ActualWidth}"
Expand Down Expand Up @@ -340,6 +340,10 @@
Margin="2"
Click="ShowAppBar"
Content="AppBar" />
<Button MinWidth="90"
Margin="2"
Click="ShowDynamicFlyout"
Content="Dynamic" />
</StackPanel>
<AdornerDecorator Margin="10"
MinWidth="100"
Expand Down
27 changes: 26 additions & 1 deletion samples/MetroDemo/ExampleWindows/FlyoutDemo.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using System.Windows;
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Threading;
using MahApps.Metro.Controls;

namespace MetroDemo.ExampleWindows
Expand Down Expand Up @@ -90,5 +93,27 @@ private void ShowSettingsRight(object sender, RoutedEventArgs e)
var flyout = (Flyout)this.Flyouts.Items[6];
flyout.Position = Position.Right;
}

private void ShowDynamicFlyout(object sender, RoutedEventArgs e) {
var flyout = new DynamicFlyout
{
Header = "Dynamic flyout"
};

// when the flyout is closed, remove it from the hosting FlyoutsControl
RoutedEventHandler closingFinishedHandler = null;
closingFinishedHandler = (o, args) =>
{
flyout.ClosingFinished -= closingFinishedHandler;
flyoutsControl.Items.Remove(flyout);
};
flyout.ClosingFinished += closingFinishedHandler;

flyoutsControl.Items.Add(flyout);

// set IsOpen to true after the binding has happened
Action a = () => flyout.IsOpen = true;
Dispatcher.BeginInvoke(DispatcherPriority.ContextIdle, a);
}
}
}
7 changes: 7 additions & 0 deletions samples/MetroDemo/MetroDemo.NET45.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@
<Compile Include="ExampleWindows\CustomFlyout.xaml.cs">
<DependentUpon>CustomFlyout.xaml</DependentUpon>
</Compile>
<Compile Include="ExampleWindows\DynamicFlyout.xaml.cs">
<DependentUpon>DynamicFlyout.xaml</DependentUpon>
</Compile>
<Compile Include="ExampleWindows\FlyoutDemo.xaml.cs">
<DependentUpon>FlyoutDemo.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -194,6 +197,10 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="ExampleWindows\DynamicFlyout.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="ExampleWindows\FlyoutDemo.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
Expand Down
7 changes: 7 additions & 0 deletions samples/MetroDemo/MetroDemo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@
<Compile Include="ExampleWindows\SizeToContentDemo.xaml.cs">
<DependentUpon>SizeToContentDemo.xaml</DependentUpon>
</Compile>
<Compile Include="ExampleWindows\DynamicFlyout.xaml.cs">
<DependentUpon>DynamicFlyout.xaml</DependentUpon>
</Compile>
<Compile Include="MainWindowViewModel.cs" />
<Compile Include="Models\Album.cs" />
<Compile Include="Models\Artist.cs" />
Expand Down Expand Up @@ -222,6 +225,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="ExampleWindows\DynamicFlyout.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
Expand Down

0 comments on commit 1a88a84

Please sign in to comment.