Skip to content

Commit 87eb68e

Browse files
committed
Merge branch 'master' into snackbar
2 parents 404496a + 77d0bc8 commit 87eb68e

File tree

17 files changed

+836
-195
lines changed

17 files changed

+836
-195
lines changed

MainDemo.Wpf/App.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Application x:Class="MaterialDesignColors.WpfExample.App"
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4-
StartupUri="ProvingGround.xaml">
4+
StartupUri="MainWindow.xaml">
55
<Application.Resources>
66
<ResourceDictionary>
77
<ResourceDictionary.MergedDictionaries>

MainDemo.Wpf/Drawers.xaml

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
<UserControl x:Class="MaterialDesignDemo.Drawers"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:local="clr-namespace:MaterialDesignDemo"
7+
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
8+
mc:Ignorable="d"
9+
d:DesignHeight="300" d:DesignWidth="300">
10+
<materialDesign:DrawerHost Margin="64" HorizontalAlignment="Center" VerticalAlignment="Center" BorderThickness="2" BorderBrush="{DynamicResource MaterialDesignDivider}">
11+
<materialDesign:DrawerHost.LeftDrawerContent>
12+
<StackPanel Margin="16">
13+
<TextBlock Margin="4" HorizontalAlignment="Center">LEFT FIELD</TextBlock>
14+
<Button Command="{x:Static materialDesign:DrawerHost.CloseDrawerCommand}"
15+
CommandParameter="{x:Static Dock.Left}"
16+
Margin="4" HorizontalAlignment="Center"
17+
Style="{DynamicResource MaterialDesignFlatButton}">
18+
CLOSE THIS
19+
</Button>
20+
<Button Command="{x:Static materialDesign:DrawerHost.CloseDrawerCommand}"
21+
Margin="4" HorizontalAlignment="Center"
22+
Style="{DynamicResource MaterialDesignFlatButton}">
23+
CLOSE ALL
24+
</Button>
25+
</StackPanel>
26+
</materialDesign:DrawerHost.LeftDrawerContent>
27+
<materialDesign:DrawerHost.TopDrawerContent>
28+
<StackPanel Margin="16" HorizontalAlignment="Center" Orientation="Horizontal">
29+
<TextBlock Margin="4" VerticalAlignment="Center">TOP BANANA</TextBlock>
30+
<Button Command="{x:Static materialDesign:DrawerHost.CloseDrawerCommand}"
31+
Style="{DynamicResource MaterialDesignFlatButton}"
32+
Margin="4" VerticalAlignment="Center">
33+
CLOSE ALL
34+
</Button>
35+
<Button Command="{x:Static materialDesign:DrawerHost.CloseDrawerCommand}"
36+
CommandParameter="{x:Static Dock.Top}"
37+
Style="{DynamicResource MaterialDesignFlatButton}"
38+
Margin="4" VerticalAlignment="Center">
39+
CLOSE THIS
40+
</Button>
41+
</StackPanel>
42+
</materialDesign:DrawerHost.TopDrawerContent>
43+
<materialDesign:DrawerHost.RightDrawerContent>
44+
<StackPanel Margin="16">
45+
<TextBlock Margin="4" HorizontalAlignment="Center">THE RIGHT STUFF</TextBlock>
46+
<Button Command="{x:Static materialDesign:DrawerHost.CloseDrawerCommand}"
47+
CommandParameter="{x:Static Dock.Right}"
48+
Margin="4" HorizontalAlignment="Center"
49+
Style="{DynamicResource MaterialDesignFlatButton}">
50+
CLOSE THIS
51+
</Button>
52+
<Button Command="{x:Static materialDesign:DrawerHost.CloseDrawerCommand}"
53+
Margin="4" HorizontalAlignment="Center"
54+
Style="{DynamicResource MaterialDesignFlatButton}">
55+
CLOSE ALL
56+
</Button>
57+
</StackPanel>
58+
</materialDesign:DrawerHost.RightDrawerContent>
59+
<materialDesign:DrawerHost.BottomDrawerContent>
60+
<StackPanel Margin="16" HorizontalAlignment="Center" Orientation="Horizontal">
61+
<TextBlock Margin="4" VerticalAlignment="Center">BOTTOM BRACKET</TextBlock>
62+
<Button Command="{x:Static materialDesign:DrawerHost.CloseDrawerCommand}"
63+
Style="{DynamicResource MaterialDesignFlatButton}"
64+
Margin="4" VerticalAlignment="Center">
65+
CLOSE ALL
66+
</Button>
67+
<Button Command="{x:Static materialDesign:DrawerHost.CloseDrawerCommand}"
68+
CommandParameter="{x:Static Dock.Bottom}"
69+
Style="{DynamicResource MaterialDesignFlatButton}"
70+
Margin="4" VerticalAlignment="Center">
71+
CLOSE THIS
72+
</Button>
73+
</StackPanel>
74+
</materialDesign:DrawerHost.BottomDrawerContent>
75+
<Grid MinWidth="480" MinHeight="480">
76+
<Grid VerticalAlignment="Center" HorizontalAlignment="Center">
77+
<Grid.RowDefinitions>
78+
<RowDefinition />
79+
<RowDefinition />
80+
<RowDefinition />
81+
</Grid.RowDefinitions>
82+
<Grid.ColumnDefinitions>
83+
<ColumnDefinition />
84+
<ColumnDefinition />
85+
<ColumnDefinition />
86+
</Grid.ColumnDefinitions>
87+
<Button Command="{x:Static materialDesign:DrawerHost.OpenDrawerCommand}"
88+
CommandParameter="{x:Static Dock.Left}"
89+
Grid.Row="1" Grid.Column="0" Margin="4">
90+
<materialDesign:PackIcon Kind="ArrowLeft" />
91+
</Button>
92+
<Button Command="{x:Static materialDesign:DrawerHost.OpenDrawerCommand}"
93+
CommandParameter="{x:Static Dock.Top}"
94+
Grid.Row="0" Grid.Column="1" Margin="4">
95+
<materialDesign:PackIcon Kind="ArrowUp" />
96+
</Button>
97+
<Button Command="{x:Static materialDesign:DrawerHost.OpenDrawerCommand}"
98+
CommandParameter="{x:Static Dock.Right}"
99+
Grid.Row="1" Grid.Column="2" Margin="4">
100+
<materialDesign:PackIcon Kind="ArrowRight" />
101+
</Button>
102+
<Button Command="{x:Static materialDesign:DrawerHost.OpenDrawerCommand}"
103+
CommandParameter="{x:Static Dock.Bottom}"
104+
Grid.Row="2" Grid.Column="1" Margin="4">
105+
<materialDesign:PackIcon Kind="ArrowDown" />
106+
</Button>
107+
<Button Command="{x:Static materialDesign:DrawerHost.OpenDrawerCommand}"
108+
Grid.Row="1" Grid.Column="1" Margin="4"
109+
Style="{DynamicResource MaterialDesignRaisedAccentButton}">
110+
<materialDesign:PackIcon Kind="ArrowAll" />
111+
</Button>
112+
</Grid>
113+
</Grid>
114+
</materialDesign:DrawerHost>
115+
</UserControl>

MainDemo.Wpf/Drawers.xaml.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using System.Windows;
7+
using System.Windows.Controls;
8+
using System.Windows.Data;
9+
using System.Windows.Documents;
10+
using System.Windows.Input;
11+
using System.Windows.Media;
12+
using System.Windows.Media.Imaging;
13+
using System.Windows.Navigation;
14+
using System.Windows.Shapes;
15+
16+
namespace MaterialDesignDemo
17+
{
18+
/// <summary>
19+
/// Interaction logic for Drawers.xaml
20+
/// </summary>
21+
public partial class Drawers : UserControl
22+
{
23+
public Drawers()
24+
{
25+
InitializeComponent();
26+
}
27+
}
28+
}

MainDemo.Wpf/MainWindow.xaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,11 @@
178178
</wpfExample:Dialogs>
179179
</domain:DemoItem.Content>
180180
</domain:DemoItem>
181+
<domain:DemoItem Name="Drawers">
182+
<domain:DemoItem.Content>
183+
<materialDesignDemo:Drawers />
184+
</domain:DemoItem.Content>
185+
</domain:DemoItem>
181186
<domain:DemoItem Name="Transitions">
182187
<domain:DemoItem.Content>
183188
<materialDesignDemo:Transitions />

MainDemo.Wpf/MaterialDesignDemo.csproj

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@
111111
<Compile Include="Domain\SimpleDateValidationRule.cs" />
112112
<Compile Include="Domain\TextFieldsViewModel.cs" />
113113
<Compile Include="Domain\TreesViewModel.cs" />
114+
<Compile Include="Drawers.xaml.cs">
115+
<DependentUpon>Drawers.xaml</DependentUpon>
116+
</Compile>
114117
<Compile Include="Expander.xaml.cs">
115118
<DependentUpon>Expander.xaml</DependentUpon>
116119
</Compile>
@@ -147,6 +150,7 @@
147150
<Compile Include="ProvingGround.xaml.cs">
148151
<DependentUpon>ProvingGround.xaml</DependentUpon>
149152
</Compile>
153+
<Compile Include="ProvingGroundStuff\MeasuringTextBox.cs" />
150154
<Compile Include="Shadows.xaml.cs">
151155
<DependentUpon>Shadows.xaml</DependentUpon>
152156
</Compile>
@@ -216,6 +220,10 @@
216220
<SubType>Designer</SubType>
217221
<Generator>MSBuild:Compile</Generator>
218222
</Page>
223+
<Page Include="Drawers.xaml">
224+
<SubType>Designer</SubType>
225+
<Generator>MSBuild:Compile</Generator>
226+
</Page>
219227
<Page Include="Expander.xaml">
220228
<SubType>Designer</SubType>
221229
<Generator>MSBuild:Compile</Generator>
@@ -416,9 +424,6 @@
416424
<ItemGroup>
417425
<Resource Include="favicon.ico" />
418426
</ItemGroup>
419-
<ItemGroup>
420-
<Folder Include="ProvingGroundStuff\" />
421-
</ItemGroup>
422427
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
423428
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
424429
Other similar extension points exist, see Microsoft.Common.targets.

MainDemo.Wpf/ProvingGround.xaml

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@
66
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
77
xmlns:converters="clr-namespace:MaterialDesignThemes.Wpf.Converters;assembly=MaterialDesignThemes.Wpf"
88
xmlns:wpfExample="clr-namespace:MaterialDesignColors.WpfExample"
9+
xmlns:provingGroundStuff="clr-namespace:MaterialDesignDemo.ProvingGroundStuff"
910
mc:Ignorable="d"
1011
d:DesignWidth="477" d:DesignHeight="272"
1112
d:DataContext="{d:DesignInstance wpfExample:ProvingGroundViewModel, d:IsDesignTimeCreatable=False}">
1213
<UserControl.Resources>
1314
<ResourceDictionary>
1415
<ResourceDictionary.MergedDictionaries>
16+
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.TextBox.xaml" />
1517
<!--
1618
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml" />
1719
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.ProgressBar.xaml" />
@@ -22,34 +24,24 @@
2224
</ResourceDictionary.MergedDictionaries>
2325

2426

27+
28+
<Style TargetType="{x:Type provingGroundStuff:MeasuringTextBox}" BasedOn="{StaticResource MaterialDesignTextBox}" />
2529

2630

2731

2832
</ResourceDictionary>
2933
</UserControl.Resources>
3034

31-
<materialDesign:DrawerHost>
32-
<materialDesign:DrawerHost.RightDrawerContent>
33-
<Grid Margin="16">
34-
<TextBlock> Hello World</TextBlock>
35-
<Button Command="{x:Static materialDesign:DrawerHost.CloseDrawerCommand}">
36-
Close
37-
</Button>
38-
</Grid>
39-
</materialDesign:DrawerHost.RightDrawerContent>
40-
<materialDesign:DrawerHost.LeftDrawerContent>
41-
<Grid Margin="16">
42-
<TextBlock>LEFT STUFF</TextBlock>
43-
<Button Command="{x:Static materialDesign:DrawerHost.CloseDrawerCommand}">
44-
Close
45-
</Button>
46-
</Grid>
47-
</materialDesign:DrawerHost.LeftDrawerContent>
48-
<StackPanel VerticalAlignment="Center" HorizontalAlignment="Center">
49-
<Button Command="{x:Static materialDesign:DrawerHost.OpenDrawerCommand}">
50-
Open sesame
51-
</Button>
35+
<Grid HorizontalAlignment="Left">
36+
<StackPanel>
37+
<provingGroundStuff:MeasuringTextBox>Hello World</provingGroundStuff:MeasuringTextBox>
38+
<provingGroundStuff:MeasuringTextBox>Hello World</provingGroundStuff:MeasuringTextBox>
39+
<provingGroundStuff:MeasuringTextBox>Hello World</provingGroundStuff:MeasuringTextBox>
40+
<provingGroundStuff:MeasuringTextBox>Hello World</provingGroundStuff:MeasuringTextBox>
41+
<provingGroundStuff:MeasuringTextBox>Hello World</provingGroundStuff:MeasuringTextBox>
42+
<provingGroundStuff:MeasuringTextBox materialDesign:HintAssist.Hint="Float">Hello World</provingGroundStuff:MeasuringTextBox>
43+
<provingGroundStuff:MeasuringTextBox materialDesign:HintAssist.IsFloating="True" materialDesign:HintAssist.Hint="Float">Hello World</provingGroundStuff:MeasuringTextBox>
5244
</StackPanel>
53-
</materialDesign:DrawerHost>
45+
</Grid>
5446

5547
</UserControl>
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Diagnostics;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
using System.Windows;
8+
using System.Windows.Controls;
9+
using MaterialDesignThemes.Wpf;
10+
11+
namespace MaterialDesignDemo.ProvingGroundStuff
12+
{
13+
public class MeasuringTextBox : TextBox
14+
{
15+
static MeasuringTextBox()
16+
{
17+
DefaultStyleKeyProperty.OverrideMetadata(typeof(MeasuringTextBox), new FrameworkPropertyMetadata(typeof(TextBox)));
18+
}
19+
20+
protected override Size ArrangeOverride(Size arrangeBounds)
21+
{
22+
var stopwatch = Stopwatch.StartNew();
23+
var result = base.ArrangeOverride(arrangeBounds);
24+
stopwatch.Stop();
25+
Debug.WriteLine($"Arrange: {stopwatch.ElapsedMilliseconds} - {stopwatch.ElapsedTicks} - ({GetHashCode()})");
26+
return result;
27+
}
28+
29+
30+
protected override Size MeasureOverride(Size constraint)
31+
{
32+
var stopwatch = Stopwatch.StartNew();
33+
var result = base.MeasureOverride(constraint);
34+
stopwatch.Stop();
35+
Debug.WriteLine($"Measure: {stopwatch.ElapsedMilliseconds} - {stopwatch.ElapsedTicks} - ({GetHashCode()})");
36+
return result;
37+
}
38+
}
39+
}

MaterialDesignThemes.Wpf/Converters/DrawerOffsetConverter.cs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Text;
66
using System.Threading.Tasks;
77
using System.Windows;
8+
using System.Windows.Controls;
89
using System.Windows.Data;
910

1011
namespace MaterialDesignThemes.Wpf.Converters
@@ -16,13 +17,19 @@ public object Convert(object value, Type targetType, object parameter, CultureIn
1617
var d = value as double? ?? 0;
1718
if (double.IsInfinity(d) || double.IsNaN(d)) d = 0;
1819

19-
if (parameter is bool && (bool)parameter)
20+
var dock = (parameter is Dock) ? (Dock)parameter : Dock.Left;
21+
switch (dock)
2022
{
21-
return 0 - d;
22-
//return new Thickness(0, 0, 0 - d, 0);
23+
case Dock.Top:
24+
return new Thickness(0, 0 - d, 0, 0);
25+
case Dock.Bottom:
26+
return new Thickness(0, 0, 0, 0 - d);
27+
case Dock.Right:
28+
return new Thickness(0, 0, 0 - d, 0);
29+
case Dock.Left:
30+
default:
31+
return new Thickness(0 - d, 0, 0, 0);
2332
}
24-
25-
return 0 - d;
2633
}
2734

2835
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)

0 commit comments

Comments
 (0)