-
-
Notifications
You must be signed in to change notification settings - Fork 2.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
Fix for FlipView : Navigation's button visibility and Transition update #2750
Merged
Merged
Changes from 8 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
2beea33
Fix for FlipView : Refresh navigation buttons' visibility when contro…
jumulr 0501fbc
Fix for FlipView : Handle navigation buttons' visibility when togglin…
jumulr 08a3b42
Fix for FlipView : Apply transition when SelectedIndex changes.
jumulr f4e9120
Merge branch 'develop' into develop
jumulr f22bfb3
Merge branch 'develop' into develop
punker76 ffdea4a
Fix for FlipView : Detailed comments for 'Apply transition when Selec…
jumulr 4ddbf60
Merge branch 'develop' of https://github.com/jumulr/MahApps.Metro.git
jumulr 2e1b9b8
Merge branch 'develop' into develop
jumulr 7b25b57
Merge branch 'develop' into develop
punker76 1f37514
Merge branch 'develop' into develop
punker76 8e0a7db
Merge branch 'develop' into develop
punker76 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
...Samples/MahApps.Metro.Demo/MahApps.Metro.Demo.Shared/Markup/EnumBindingSourceExtension.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
using System; | ||
using System.Windows.Markup; | ||
|
||
namespace MetroDemo.Markup | ||
{ | ||
|
||
/// <summary> | ||
/// Markup extension for Enum values. | ||
/// </summary> | ||
public class EnumBindingSourceExtension | ||
: MarkupExtension | ||
{ | ||
private Type _EnumType; | ||
|
||
/// <summary> | ||
/// Gets or sets the type of the Enum. | ||
/// </summary> | ||
/// <exception cref="ArgumentException">Value is not an Enum type.</exception> | ||
public Type EnumType | ||
{ | ||
get { return this._EnumType; } | ||
set | ||
{ | ||
if (!Object.Equals(value, this.EnumType)) | ||
{ | ||
if (!Object.Equals(value, null) && !(Nullable.GetUnderlyingType(value) ?? value).IsEnum) | ||
throw new ArgumentException("Type must be an Enum."); | ||
|
||
this._EnumType = value; | ||
} | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of EnumBindingSourceExtension. | ||
/// </summary> | ||
public EnumBindingSourceExtension() { } | ||
|
||
/// <summary> | ||
/// Initializes a new instance of EnumBindingSourceExtension. | ||
/// </summary> | ||
/// <param name="enumType">The type of the Enum.</param> | ||
public EnumBindingSourceExtension(Type enumType) | ||
{ | ||
this.EnumType = enumType; | ||
} | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <param name="serviceProvider">Object that can provide services for the markup extension.</param> | ||
/// <returns>The values of the Enum.</returns> | ||
/// <exception cref="InvalidOperationException">The type of the Enum is undefined.</exception> | ||
public override object ProvideValue(IServiceProvider serviceProvider) | ||
{ | ||
if (Object.Equals(this.EnumType, null)) | ||
throw new InvalidOperationException("The type of the Enum is undefined."); | ||
|
||
var underlyingEnumType = Nullable.GetUnderlyingType(this.EnumType) ?? this.EnumType; | ||
var enumValues = Enum.GetValues(underlyingEnumType); | ||
if (underlyingEnumType.Equals(this.EnumType)) | ||
return enumValues; | ||
|
||
var nullableEnumValues = Array.CreateInstance(underlyingEnumType, enumValues.Length); | ||
enumValues.CopyTo(nullableEnumValues, 1); | ||
return nullableEnumValues; | ||
} | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
...ahApps.Metro.Demo/MahApps.Metro.Demo.Shared/ValueConverter/Int32IndexToNumberConverter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Globalization; | ||
using System.Text; | ||
using System.Windows.Data; | ||
using System.Windows.Markup; | ||
|
||
namespace MetroDemo.ValueConverter | ||
{ | ||
/// <summary> | ||
/// Converts an Int32 zero-based index to a one-based number. | ||
/// </summary> | ||
public class Int32IndexToNumberConverter | ||
: MarkupExtension , IValueConverter | ||
{ | ||
/// <summary> | ||
/// Returns the value for the target property of this markup extension. | ||
/// </summary> | ||
/// <param name="serviceProvider">Object that can provide services for the markup extension.</param> | ||
/// <returns>Reference to the instance of this Int32IndexToNumberConverter.</returns> | ||
public override object ProvideValue(IServiceProvider serviceProvider) | ||
{ | ||
return this; | ||
} | ||
|
||
/// <summary> | ||
/// Converts an Int32 zero-based index to a one-based number. | ||
/// </summary> | ||
/// <param name="value">Int32 zero-based index.</param> | ||
/// <param name="targetType">Ignored.</param> | ||
/// <param name="parameter">Ignored.</param> | ||
/// <param name="culture">Ignored.</param> | ||
/// <returns>Int32 one-based number.</returns> | ||
/// <exception cref="FormatException">Incorrect format.</exception> | ||
/// <exception cref="InvalidCastException">Unsupported convversion.</exception> | ||
/// <exception cref="OverflowException">Out of range of Int32.</exception> | ||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
return System.Convert.ToInt32(value) + 1; | ||
} | ||
|
||
/// <summary> | ||
/// Converts an Int32 one-based number to a zero-based index. | ||
/// </summary> | ||
/// <param name="value">Int32 one-based number.</param> | ||
/// <param name="targetType">Ignored.</param> | ||
/// <param name="parameter">Ignored.</param> | ||
/// <param name="culture">Ignored.</param> | ||
/// <returns>Int32 zero-based index.</returns> | ||
/// <exception cref="FormatException">Incorrect format.</exception> | ||
/// <exception cref="InvalidCastException">Unsupported convversion.</exception> | ||
/// <exception cref="OverflowException">Out of range of Int32.</exception> | ||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
return System.Convert.ToInt32(value) - 1; | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Why not starting from 0? Then you don't need the Int32IndexToNumberConverter.
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.
You're absolutely right.
It's just that users tend to prefer message 'Viewing item 1 on 2' than 'Viewing item 0 on 1'.
Hence the shift of 1.