-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Expander control #707
Expander control #707
Changes from 8 commits
0c90652
c717d39
52da7d2
08f869f
6acfb3f
e79c07f
5da6ea1
0c6c077
0c2c7d3
4224209
491f2b9
5a94a19
e3c6e22
8dbd4cc
6a88090
dd06da0
b0754c0
7ae1949
a1e170f
ee2c4e8
033716c
debf8b7
b102c1a
c614947
e0a21eb
1f0a6a4
c45a336
26174a5
dd13fc1
ddedd7d
8a84377
7585cca
80838d1
10bc319
e354d0e
13e5490
3f5a694
ff387b9
b3eddc0
003cca7
6506f54
629ed18
09fb4f2
4b97404
c0c638b
098fe63
e32c26d
9c65dbe
6c44153
79780c0
0067bdf
7981b2e
a8a2f97
3d6b71b
3fcf667
5d5d6bb
10be4e4
7260174
9b7231b
37a0f4e
3a4afce
0bae36d
7580e50
d75e564
264bca7
b97e5d5
19cbcdd
31495b6
91f09a8
4c887d5
0a5c6c9
5ae03f6
982b3af
d00af79
64b22d8
0571dc8
e556e4e
6e39206
d2c2396
21a32b8
9cbe79c
69dfdc0
1d409d4
723d623
e7d721f
83b89e8
dc53e29
b7dd44f
4db48ad
fb5fba7
8ac39aa
4ea441f
7f5d808
c31b876
0553b90
427e171
be25e6f
366835a
8397e9c
d80ca5d
5ab905b
3d583d4
9343c7b
d81ab0d
af4768a
cdae985
091f033
18730cf
1ef6c32
a72e16c
662a47b
f81f144
defbc5a
d36cba5
a2c05fb
eb91388
fbefd4b
a2cf728
7b0b075
11c2fa5
4fc4c65
56922f2
82768ca
58833ab
47a78b2
7e971fb
a373dad
0082fa3
e3f4e5c
a2ef662
3f892ac
457411d
4aefb1a
8c5f616
7910011
67bf1f2
c43fd51
e53efb0
5ba367a
b4923e2
f809240
52ba759
536639d
1d52c76
769e2a9
a87a410
2fb5ac5
7f382b9
3145e35
db64038
b72281b
0c54d64
e34b53d
07b391b
573b0a0
fe0561f
e458e17
ef3a35c
d78c74c
18ad3c1
8efd55f
af0d621
58fd753
d633ddf
06e9ccb
13aa821
90dc36b
787e860
1d678b8
da18114
f188990
8e55521
8e8bef4
419f93b
01be039
c5c7063
a070ee7
4defc09
185e6bf
2057d1c
d60de6c
fc4233c
efb3721
cefa617
a9bae0a
857abc0
4ba8f26
ac2c96b
17e2b77
73c890e
fa5d80c
6c3c4e4
695da68
65aae93
cf09a0b
195a3c1
f78a6a6
ea4e3c6
18fa31e
3ced3c1
ead9f06
6f6033e
0aea9d4
20ca759
30d0da9
0012aee
6d38c28
eee720d
d6c07b1
5d31b61
38b5cfd
3bbe683
fcdd124
e5c9418
30d3478
896b20a
574fbae
500838c
2bcabe3
a119361
c38d25f
d3fc982
9ebd0c1
edbfd01
e910f1d
53f1af3
8d94332
8352f37
47b6215
6cdb65f
659c327
a5a111f
2b99646
a66029e
e8fcb11
9d8d257
d149618
7a65074
722a5df
e23487c
914d8d6
279aede
f7aeeb4
99b7191
635f4c3
0f36d1e
c34b32a
6f3aa06
ae4c76a
5d4e7ec
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<Page | ||
x:Class="Microsoft.Toolkit.Uwp.SampleApp.SamplePages.ExpanderPage" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
mc:Ignorable="d"> | ||
|
||
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> | ||
<StackPanel Margin="20"> | ||
<controls:Expander x:Name="Expander1" VerticalAlignment="Top" Margin="0,0,0,10" | ||
Header="This is the header - expander 1" | ||
IsExpanded="{Binding Path=IsExpanded1.Value, Mode=TwoWay}"> | ||
<Grid Height="250" Background="{StaticResource Brush-Grey-01}"> | ||
<TextBlock HorizontalAlignment="Center" | ||
TextWrapping="Wrap" | ||
Text="This is the content" | ||
VerticalAlignment="Center" | ||
Style="{StaticResource HeaderTextBlockStyle}" /> | ||
</Grid> | ||
</controls:Expander> | ||
|
||
<controls:Expander x:Name="Expander2" VerticalAlignment="Top" Margin="0" | ||
Header="This is the header - expander 2" | ||
IsExpanded="{Binding Path=IsExpanded2.Value, Mode=TwoWay}"> | ||
<Grid Height="250" Background="{StaticResource Brush-Grey-02}"> | ||
<TextBlock HorizontalAlignment="Center" | ||
TextWrapping="Wrap" | ||
Text="This is the content" | ||
VerticalAlignment="Center" | ||
Style="{StaticResource HeaderTextBlockStyle}" /> | ||
</Grid> | ||
</controls:Expander> | ||
</StackPanel> | ||
</Grid> | ||
</Page> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// ****************************************************************** | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// This code is licensed under the MIT License (MIT). | ||
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | ||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, | ||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH | ||
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE. | ||
// ****************************************************************** | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Runtime.InteropServices.WindowsRuntime; | ||
using Microsoft.Toolkit.Uwp.SampleApp.Models; | ||
using Windows.Foundation; | ||
using Windows.Foundation.Collections; | ||
using Windows.UI.Xaml; | ||
using Windows.UI.Xaml.Controls; | ||
using Windows.UI.Xaml.Controls.Primitives; | ||
using Windows.UI.Xaml.Data; | ||
using Windows.UI.Xaml.Input; | ||
using Windows.UI.Xaml.Media; | ||
using Windows.UI.Xaml.Navigation; | ||
|
||
namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages | ||
{ | ||
/// <summary> | ||
/// A page that shows how to use the Expander control. | ||
/// </summary> | ||
public sealed partial class ExpanderPage : Page | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="ExpanderPage"/> class. | ||
/// </summary> | ||
public ExpanderPage() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
/// <summary> | ||
/// Invoked when the Page is loaded and becomes the current source of a parent Frame. | ||
/// </summary> | ||
/// <param name="e">Event data that can be examined by overriding code. The event data is representative of the pending navigation that will load the current Page. Usually the most relevant property to examine is Parameter.</param> | ||
protected override void OnNavigatedTo(NavigationEventArgs e) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So sorry but due to recent changes this method has to be removed :( |
||
{ | ||
base.OnNavigatedTo(e); | ||
|
||
var propertyDesc = e.Parameter as PropertyDescriptor; | ||
|
||
if (propertyDesc != null) | ||
{ | ||
DataContext = propertyDesc.Expando; | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<Page | ||
x:Class="Microsoft.Toolkit.Uwp.SampleApp.SamplePages.ExpanderPage" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
mc:Ignorable="d"> | ||
|
||
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> | ||
<StackPanel Margin="20"> | ||
<controls:Expander x:Name="Expander1" VerticalAlignment="Top" Margin="0,0,0,10" | ||
Header="This is the header - expander 1" | ||
IsExpanded="@[IsExpanded1:Bool:False]"> | ||
<Grid Height="250" Background="#FFF5F1D9"> | ||
<TextBlock HorizontalAlignment="Center" | ||
TextWrapping="Wrap" | ||
Text="This is the content" | ||
VerticalAlignment="Center" | ||
Style="{StaticResource HeaderTextBlockStyle}" /> | ||
</Grid> | ||
</controls:Expander> | ||
|
||
<controls:Expander x:Name="Expander2" VerticalAlignment="Top" Margin="0" | ||
Header="This is the header - expander 2" | ||
IsExpanded="@[IsExpanded2:Bool:True]"> | ||
<Grid Height="250" Background="#FFD9F1F5"> | ||
<TextBlock HorizontalAlignment="Center" | ||
TextWrapping="Wrap" | ||
Text="This is the content" | ||
VerticalAlignment="Center" | ||
Style="{StaticResource HeaderTextBlockStyle}" /> | ||
</Grid> | ||
</controls:Expander> | ||
</StackPanel> | ||
</Grid> | ||
</Page> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
{ | ||
"dependencies": { | ||
"Microsoft.Graph": "1.1.1", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @deltakosh I needed to add Microsoft.Graph reference in the SamplesApp either way I could not be able to compile the app.. (using Visual Studio 2017 Community RC 15.0.26020.0). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok I'll check |
||
"Microsoft.NETCore.UniversalWindowsPlatform": "5.1.0", | ||
"Microsoft.Xaml.Behaviors.Uwp.Managed": "1.1.0", | ||
"Newtonsoft.Json": "9.0.1", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// ****************************************************************** | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// This code is licensed under the MIT License (MIT). | ||
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | ||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, | ||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH | ||
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE. | ||
// ****************************************************************** | ||
|
||
namespace Microsoft.Toolkit.Uwp.UI.Controls | ||
{ | ||
/// <summary> | ||
/// The <see cref="Expander"/> control allows user to show/hide content based on a boolean state | ||
/// </summary> | ||
public partial class Expander | ||
{ | ||
public const string GroupContent = "ExpandedStates"; | ||
public const string StateContentExpanded = "Expanded"; | ||
public const string StateContentCollapsed = "Collapsed"; | ||
|
||
public const string ExpanderToggleButtonPart = "PART_ExpanderToggleButton"; | ||
public const string MainContentRowPart = "PART_MainContentRow"; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// ****************************************************************** | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// This code is licensed under the MIT License (MIT). | ||
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | ||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, | ||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH | ||
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE. | ||
// ****************************************************************** | ||
|
||
using System; | ||
|
||
namespace Microsoft.Toolkit.Uwp.UI.Controls | ||
{ | ||
/// <summary> | ||
/// The <see cref="Expander"/> control allows user to show/hide content based on a boolean state | ||
/// </summary> | ||
public partial class Expander | ||
{ | ||
/// <summary> | ||
/// Fires when the expander is opened | ||
/// </summary> | ||
public event EventHandler Expanded; | ||
|
||
/// <summary> | ||
/// Fires when the expander is closed | ||
/// </summary> | ||
public event EventHandler Collapsed; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// ****************************************************************** | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// This code is licensed under the MIT License (MIT). | ||
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | ||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, | ||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH | ||
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE. | ||
// ****************************************************************** | ||
|
||
using Windows.UI.Xaml; | ||
|
||
namespace Microsoft.Toolkit.Uwp.UI.Controls | ||
{ | ||
/// <summary> | ||
/// The <see cref="Expander"/> control allows user to show/hide content based on a boolean state | ||
/// </summary> | ||
public partial class Expander | ||
{ | ||
public static readonly DependencyProperty HeaderProperty = | ||
DependencyProperty.Register(nameof(Header), typeof(string), typeof(Expander), new PropertyMetadata(null)); | ||
|
||
public static readonly DependencyProperty HeaderTemplateProperty = | ||
DependencyProperty.Register(nameof(HeaderTemplate), typeof(DataTemplate), typeof(Expander), new PropertyMetadata(null)); | ||
|
||
public static readonly DependencyProperty IsExpandedProperty = | ||
DependencyProperty.Register(nameof(IsExpanded), typeof(bool), typeof(Expander), new PropertyMetadata(false, OnIsExpandedPropertyChanged)); | ||
|
||
public string Header | ||
{ | ||
get { return (string)GetValue(HeaderProperty); } | ||
set { SetValue(HeaderProperty, value); } | ||
} | ||
|
||
public DataTemplate HeaderTemplate | ||
{ | ||
get { return (DataTemplate)GetValue(HeaderTemplateProperty); } | ||
set { SetValue(HeaderTemplateProperty, value); } | ||
} | ||
|
||
public bool IsExpanded | ||
{ | ||
get { return (bool)GetValue(IsExpandedProperty); } | ||
set { SetValue(IsExpandedProperty, value); } | ||
} | ||
|
||
private static void OnIsExpandedPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) | ||
{ | ||
var expander = d as Expander; | ||
|
||
bool isExpanded = (bool)e.NewValue; | ||
if (isExpanded) | ||
{ | ||
expander.ExpandControl(); | ||
} | ||
else | ||
{ | ||
expander.CollapseControl(); | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// ****************************************************************** | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// This code is licensed under the MIT License (MIT). | ||
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | ||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, | ||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH | ||
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE. | ||
// ****************************************************************** | ||
|
||
using System; | ||
using Windows.UI.Xaml; | ||
using Windows.UI.Xaml.Controls; | ||
using Windows.UI.Xaml.Controls.Primitives; | ||
using Windows.UI.Xaml.Markup; | ||
|
||
namespace Microsoft.Toolkit.Uwp.UI.Controls | ||
{ | ||
/// <summary> | ||
/// The <see cref="Expander"/> control allows user to show/hide content based on a boolean state | ||
/// </summary> | ||
[TemplateVisualState(Name = StateContentExpanded, GroupName = GroupContent)] | ||
[TemplateVisualState(Name = StateContentCollapsed, GroupName = GroupContent)] | ||
[TemplatePart(Name = ExpanderToggleButtonPart, Type = typeof(ToggleButton))] | ||
[ContentProperty(Name = "Content")] | ||
public partial class Expander : ContentControl | ||
{ | ||
public Expander() | ||
{ | ||
DefaultStyleKey = typeof(Expander); | ||
} | ||
|
||
protected override void OnApplyTemplate() | ||
{ | ||
base.OnApplyTemplate(); | ||
|
||
if (!IsExpanded) | ||
{ | ||
VisualStateManager.GoToState(this, StateContentCollapsed, false); | ||
} | ||
} | ||
|
||
private void ExpandControl() | ||
{ | ||
VisualStateManager.GoToState(this, StateContentExpanded, true); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fire a new |
||
Expanded?.Invoke(this, new EventArgs()); | ||
} | ||
|
||
private void CollapseControl() | ||
{ | ||
VisualStateManager.GoToState(this, StateContentCollapsed, true); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fire a new |
||
Collapsed?.Invoke(this, new EventArgs()); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't have, please revert