Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add a default style - Add a BannerText property
- Loading branch information
Showing
6 changed files
with
185 additions
and
62 deletions.
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
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,60 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System.Windows; | ||
using System.Windows.Controls; | ||
|
||
namespace MahApps.Metro.Controls | ||
{ | ||
public class FlipViewItem : ContentControl | ||
{ | ||
/// <summary>Identifies the <see cref="BannerText"/> dependency property.</summary> | ||
public static readonly DependencyProperty BannerTextProperty | ||
= DependencyProperty.Register(nameof(BannerText), | ||
typeof(object), | ||
typeof(FlipViewItem), | ||
new FrameworkPropertyMetadata("Banner", | ||
FrameworkPropertyMetadataOptions.AffectsRender, | ||
(d, e) => ((FlipViewItem)d).ExecuteWhenLoaded(() => ((FlipViewItem)d).Owner?.SetCurrentValue(FlipView.BannerTextProperty, e.NewValue)))); | ||
|
||
/// <summary> | ||
/// Gets or sets the banner text. | ||
/// </summary> | ||
public object BannerText | ||
{ | ||
get => this.GetValue(BannerTextProperty); | ||
set => this.SetValue(BannerTextProperty, value); | ||
} | ||
|
||
/// <summary>Identifies the <see cref="Owner"/> dependency property.</summary> | ||
private static readonly DependencyPropertyKey OwnerPropertyKey = | ||
DependencyProperty.RegisterReadOnly(nameof(Owner), | ||
typeof(FlipView), | ||
typeof(FlipViewItem), | ||
new PropertyMetadata(null)); | ||
|
||
/// <summary>Identifies the <see cref="Owner"/> dependency property.</summary> | ||
public static readonly DependencyProperty OwnerProperty = OwnerPropertyKey.DependencyProperty; | ||
|
||
public FlipView Owner | ||
{ | ||
get => (FlipView)this.GetValue(OwnerProperty); | ||
protected set => this.SetValue(OwnerPropertyKey, value); | ||
} | ||
|
||
static FlipViewItem() | ||
{ | ||
DefaultStyleKeyProperty.OverrideMetadata(typeof(FlipViewItem), new FrameworkPropertyMetadata(typeof(FlipViewItem))); | ||
} | ||
|
||
/// <inheritdoc /> | ||
public override void OnApplyTemplate() | ||
{ | ||
base.OnApplyTemplate(); | ||
|
||
var flipView = ItemsControl.ItemsControlFromItemContainer(this) as FlipView; | ||
this.SetValue(OwnerPropertyKey, flipView); | ||
} | ||
} | ||
} |
Oops, something went wrong.