Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions MahApps.Metro/Controls/FlipView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ private static void ExecuteWhenLoaded(FlipView flipview, Action body)
public static readonly DependencyProperty IsBannerEnabledProperty = DependencyProperty.Register("IsBannerEnabled", typeof(bool), typeof(FlipView), new UIPropertyMetadata(true, OnIsBannerEnabledPropertyChangedCallback));
public static readonly DependencyProperty BannerTextProperty = DependencyProperty.Register("BannerText", typeof(string), typeof(FlipView), new FrameworkPropertyMetadata("Banner", FrameworkPropertyMetadataOptions.AffectsRender, (d, e) => ExecuteWhenLoaded(((FlipView)d), () => ((FlipView)d).ChangeBannerText((string)e.NewValue))));
public static readonly DependencyProperty CircularNavigationProperty = DependencyProperty.Register("CircularNavigation", typeof(bool), typeof(FlipView), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender, (d, e) => ((FlipView)d).DetectControlButtonsStatus()));
public static readonly DependencyProperty IsNavigationEnabledProperty = DependencyProperty.Register("IsNavigationEnabled", typeof(bool), typeof(FlipView), new UIPropertyMetadata(true, OnIsNavigationEnabledPropertyChangedCallback));

public TransitionType UpTransition
{
Expand Down Expand Up @@ -443,6 +444,15 @@ public bool CircularNavigation
set { SetValue(CircularNavigationProperty, value); }
}

/// <summary>
/// Gets/sets whether the FlipView's NavigationButton is visible.
/// </summary>
public bool IsNavigationEnabled
{
get { return (bool)GetValue(IsNavigationEnabledProperty); }
set { SetValue(IsNavigationEnabledProperty, value); }
}

private void ChangeBannerText(string value = null)
{
if (IsBannerEnabled)
Expand Down Expand Up @@ -522,5 +532,37 @@ private static void OnIsBannerEnabledPropertyChangedCallback(DependencyObject d,
}
}

private static void OnIsNavigationEnabledPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var flipview = ((FlipView)d);

if (!flipview.IsLoaded)
{
//wait to be loaded?
ExecuteWhenLoaded(flipview, () => {
flipview.ApplyTemplate();

if ((bool)e.NewValue)
{
flipview.ShowControlButtons();
}
else
{
flipview.HideControlButtons();
}
});
}
else
{
if ((bool)e.NewValue)
{
flipview.ShowControlButtons();
}
else
{
flipview.HideControlButtons();
}
}
}
}
}
6 changes: 6 additions & 0 deletions samples/MetroDemo/ExampleViews/OtherExamples.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,17 @@
Margin="5 0"
Content="Circular Navi"
IsChecked="False" />
<CheckBox x:Name="ShowNaviCheckBox"
Margin="5 0"
Content="Show NaviButtons"
IsChecked="True" />
</StackPanel>
<Controls:FlipView Height="200"
Margin="0 0 10 0"
IsBannerEnabled="{Binding ElementName=ShowBannerCheckBox, Path=IsChecked, UpdateSourceTrigger=PropertyChanged}"
MouseOverGlowEnabled="{Binding ElementName=ShowMouseOverCheckBox, Path=IsChecked, UpdateSourceTrigger=PropertyChanged}"
CircularNavigation="{Binding ElementName=CircularNaviCheckBox, Path=IsChecked, UpdateSourceTrigger=PropertyChanged}"
IsNavigationEnabled="{Binding ElementName=ShowNaviCheckBox, Path=IsChecked, UpdateSourceTrigger=PropertyChanged}"
SelectionChanged="FlipView_SelectionChanged">
<Controls:FlipView.Items>
<Grid Background="#2E8DEF">
Expand Down Expand Up @@ -162,6 +167,7 @@
IsBannerEnabled="{Binding ElementName=ShowBannerCheckBox, Path=IsChecked, UpdateSourceTrigger=PropertyChanged}"
MouseOverGlowEnabled="{Binding ElementName=ShowMouseOverCheckBox, Path=IsChecked, UpdateSourceTrigger=PropertyChanged}"
CircularNavigation="{Binding ElementName=CircularNaviCheckBox, Path=IsChecked, UpdateSourceTrigger=PropertyChanged}"
IsNavigationEnabled="{Binding ElementName=ShowNaviCheckBox, Path=IsChecked, UpdateSourceTrigger=PropertyChanged}"
ItemTemplateSelector="{Binding FlipViewTemplateSelector, UpdateSourceTrigger=PropertyChanged}"
ItemsSource="{Binding FlipViewImages, UpdateSourceTrigger=PropertyChanged}" />
</StackPanel>
Expand Down