Skip to content
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

FlipView Patch #3 #499

Merged
merged 4 commits into from
Jun 1, 2013
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
34 changes: 18 additions & 16 deletions MahApps.Metro/Controls/FlipView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public class FlipView : Selector
/// </summary>
private bool loaded = false;

private bool controls_visibility_override = false;

static FlipView()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(FlipView), new FrameworkPropertyMetadata(typeof(FlipView)));
Expand All @@ -72,24 +74,14 @@ void FlipView_SelectionChanged(object sender, SelectionChangedEventArgs e)

private void DetectControlButtonsStatus()
{
if (controls_visibility_override) return;

if (backButton == null || forwardButton == null) return;

if (Items.Count > 0)
{
if (SelectedIndex == 0)
{
backButton.Visibility = System.Windows.Visibility.Hidden;
forwardButton.Visibility = System.Windows.Visibility.Visible;
}
else
if (SelectedIndex == Items.Count - 1)
{
backButton.Visibility = System.Windows.Visibility.Visible;
forwardButton.Visibility = System.Windows.Visibility.Hidden;
}
else
{
backButton.Visibility = System.Windows.Visibility.Visible;
forwardButton.Visibility = System.Windows.Visibility.Visible;
}
backButton.Visibility = SelectedIndex == 0 ? System.Windows.Visibility.Hidden : System.Windows.Visibility.Visible;
forwardButton.Visibility = SelectedIndex == (Items.Count - 1) ? System.Windows.Visibility.Hidden : System.Windows.Visibility.Visible;
}
else
{
Expand Down Expand Up @@ -178,6 +170,13 @@ protected override void OnItemsSourceChanged(System.Collections.IEnumerable oldV
SelectedIndex = 0;
}

protected override void OnItemsChanged(System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
base.OnItemsChanged(e);

DetectControlButtonsStatus();
}

void forwardButton_Click(object sender, RoutedEventArgs e)
{
GoForward();
Expand Down Expand Up @@ -208,6 +207,8 @@ public void GoForward()

public void ShowControlButtons()
{
controls_visibility_override = false;

ExecuteWhenLoaded(this, () =>
{
backButton.Visibility = System.Windows.Visibility.Visible;
Expand All @@ -216,6 +217,7 @@ public void ShowControlButtons()
}
public void HideControlButtons()
{
controls_visibility_override = true;
ExecuteWhenLoaded(this, () =>
{
backButton.Visibility = System.Windows.Visibility.Hidden;
Expand Down
2 changes: 1 addition & 1 deletion MahApps.Metro/Themes/FlipView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<Path Width="16" Height="18" Canvas.Left="15.9063" Canvas.Top="14.75" Stretch="Fill" Fill="{DynamicResource BlackBrush}" Data="F1 M 25.1563,23.75L 23.1563,21.75L 15.9063,14.75L 22.4063,14.75L 31.9063,23.75L 22.4063,32.75L 15.9063,32.75L 23.1563,25.75L 25.1563,23.75 Z " />
</Button>

<Grid VerticalAlignment="Bottom" Height="0" x:Name="PART_BannerGrid" Panel.ZIndex="6" Opacity="0.9">
<Grid VerticalAlignment="Bottom" Height="0" x:Name="PART_BannerGrid" Panel.ZIndex="6" Opacity="0.85">
<Grid.Background>
<SolidColorBrush Color="{DynamicResource BlackColor}"/>
</Grid.Background>
Expand Down