Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: MahApps/MahApps.Metro
...
head fork: MahApps/MahApps.Metro
Checking mergeability… Don't worry, you can still create the pull request.
  • 3 commits
  • 6 files changed
  • 0 commit comments
  • 1 contributor
View
30 MahApps.Metro/Controls/MetroContentControl.cs
@@ -8,6 +8,15 @@ namespace MahApps.Metro.Controls
/// </summary>
public class MetroContentControl : ContentControl
{
+ public static readonly DependencyProperty ReverseTransitionProperty = DependencyProperty.Register("ReverseTransition", typeof(bool), typeof(MetroContentControl), new FrameworkPropertyMetadata(false));
+
+ public bool ReverseTransition
+ {
+ get { return (bool)GetValue(ReverseTransitionProperty); }
+ set { SetValue(ReverseTransitionProperty, value); }
+ }
+
+
public MetroContentControl()
{
DefaultStyleKey = typeof(MetroContentControl);
@@ -21,25 +30,34 @@ public MetroContentControl()
void MetroContentControlIsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
{
if (!IsVisible)
- VisualStateManager.GoToState(this, "AfterUnLoaded", false);
+ VisualStateManager.GoToState(this, ReverseTransition ? "AfterUnLoadedReverse" : "AfterUnLoaded", false);
else
- VisualStateManager.GoToState(this, "AfterLoaded", true);
+ VisualStateManager.GoToState(this, ReverseTransition ? "AfterLoadedReverse" : "AfterLoaded", true);
}
private void MetroContentControlUnloaded(object sender, RoutedEventArgs e)
{
- VisualStateManager.GoToState(this, "AfterUnLoaded", false);
+ VisualStateManager.GoToState(this, ReverseTransition ? "AfterUnLoadedReverse" : "AfterUnLoaded", false);
}
private void MetroContentControlLoaded(object sender, RoutedEventArgs e)
{
- VisualStateManager.GoToState(this, "AfterLoaded", true);
+ VisualStateManager.GoToState(this, ReverseTransition ? "AfterLoadedReverse" : "AfterLoaded", true);
}
public void Reload()
{
- VisualStateManager.GoToState(this, "BeforeLoaded", true);
- VisualStateManager.GoToState(this, "AfterLoaded", true);
+ if (ReverseTransition)
+ {
+ VisualStateManager.GoToState(this, "BeforeLoaded", true);
+ VisualStateManager.GoToState(this, "AfterUnLoadedReverse", true);
+ }
+ else
+ {
+ VisualStateManager.GoToState(this, "BeforeLoaded", true);
+ VisualStateManager.GoToState(this, "AfterLoaded", true);
+ }
+
}
}
}
View
35 MahApps.Metro/Controls/PanoramaGroup.cs
@@ -1,12 +1,16 @@
-using System.ComponentModel;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Windows.Data;
namespace MahApps.Metro.Controls
{
/// <summary>
/// Represents a grouping of tiles
/// </summary>
- public class PanoramaGroup
+ public class PanoramaGroup : INotifyPropertyChanged
{
+ public event PropertyChangedEventHandler PropertyChanged;
+
public string Header { get; private set; }
public ICollectionView Tiles { get; private set; }
@@ -15,5 +19,32 @@ public PanoramaGroup(string header, ICollectionView tiles)
Header = header;
Tiles = tiles;
}
+
+ public PanoramaGroup(string header, IEnumerable<object> tiles)
+ {
+ Header = header;
+ Tiles = CollectionViewSource.GetDefaultView(tiles);
+ }
+
+ public PanoramaGroup(string header)
+ {
+ Header = header;
+ }
+
+ public void SetSource(IEnumerable<object> tiles)
+ {
+ Tiles = CollectionViewSource.GetDefaultView(tiles);
+ OnPropertyChanged("Tiles");
+ }
+
+ protected void OnPropertyChanged(string name)
+ {
+ PropertyChangedEventHandler handler = PropertyChanged;
+ if (handler != null)
+ {
+ handler(this, new PropertyChangedEventArgs(name));
+ }
+ }
+
}
}
View
68 MahApps.Metro/Themes/MetroContentControl.xaml
@@ -16,21 +16,29 @@
<VisualStateGroup x:Name="LayoutStates">
<VisualState x:Name="AfterLoaded">
<Storyboard>
- <DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
- Storyboard.TargetProperty="(UIElement.Opacity)"
- Storyboard.TargetName="root">
- <SplineDoubleKeyFrame KeyTime="00:00:00"
- Value="0" />
- <SplineDoubleKeyFrame KeyTime="00:00:00.400"
- Value="1" />
+ <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="root">
+ <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0" />
+ <SplineDoubleKeyFrame KeyTime="00:00:00.400" Value="1" />
</DoubleAnimationUsingKeyFrames>
- <DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
- Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.X)"
- Storyboard.TargetName="root">
- <SplineDoubleKeyFrame KeyTime="00:00:00"
- Value="-30" />
- <EasingDoubleKeyFrame KeyTime="00:00:00.700"
- Value="0">
+ <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.X)" Storyboard.TargetName="root">
+ <SplineDoubleKeyFrame KeyTime="00:00:00" Value="30" />
+ <EasingDoubleKeyFrame KeyTime="00:00:00.700" Value="0">
+ <EasingDoubleKeyFrame.EasingFunction>
+ <CubicEase EasingMode="EaseOut" />
+ </EasingDoubleKeyFrame.EasingFunction>
+ </EasingDoubleKeyFrame>
+ </DoubleAnimationUsingKeyFrames>
+ </Storyboard>
+ </VisualState>
+ <VisualState x:Name="AfterLoadedReverse">
+ <Storyboard>
+ <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="root">
+ <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0" />
+ <SplineDoubleKeyFrame KeyTime="00:00:00.400" Value="1" />
+ </DoubleAnimationUsingKeyFrames>
+ <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.X)" Storyboard.TargetName="root">
+ <SplineDoubleKeyFrame KeyTime="00:00:00" Value="-30" />
+ <EasingDoubleKeyFrame KeyTime="00:00:00.700" Value="0">
<EasingDoubleKeyFrame.EasingFunction>
<CubicEase EasingMode="EaseOut" />
</EasingDoubleKeyFrame.EasingFunction>
@@ -40,21 +48,25 @@
</VisualState>
<VisualState x:Name="AfterUnLoaded">
<Storyboard>
- <DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
- Storyboard.TargetProperty="(UIElement.Opacity)"
- Storyboard.TargetName="root">
- <SplineDoubleKeyFrame KeyTime="00:00:00"
- Value="1" />
- <SplineDoubleKeyFrame KeyTime="00:00:00.100"
- Value="0" />
+ <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="root">
+ <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1" />
+ <SplineDoubleKeyFrame KeyTime="00:00:00.100" Value="0" />
+ </DoubleAnimationUsingKeyFrames>
+ <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.X)" Storyboard.TargetName="root">
+ <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0" />
+ <SplineDoubleKeyFrame KeyTime="00:00:00.100" Value="30" />
+ </DoubleAnimationUsingKeyFrames>
+ </Storyboard>
+ </VisualState>
+ <VisualState x:Name="AfterUnLoadedReverse">
+ <Storyboard>
+ <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="root">
+ <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1" />
+ <SplineDoubleKeyFrame KeyTime="00:00:00.100" Value="0" />
</DoubleAnimationUsingKeyFrames>
- <DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
- Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.X)"
- Storyboard.TargetName="root">
- <SplineDoubleKeyFrame KeyTime="00:00:00"
- Value="0" />
- <SplineDoubleKeyFrame KeyTime="00:00:00.100"
- Value="-30" />
+ <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.X)" Storyboard.TargetName="root">
+ <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0" />
+ <SplineDoubleKeyFrame KeyTime="00:00:00.100" Value="-30" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
View
4 MahApps.Metro/Themes/Panorama.xaml
@@ -50,16 +50,16 @@
<WrapPanel.Height>
<MultiBinding Converter="{StaticResource PanoramaGroupHeightConverter}">
<Binding Path="ItemBox" RelativeSource="{RelativeSource AncestorType={x:Type Controls:Panorama}, Mode=FindAncestor}" />
- <Binding Path="GroupHeight" RelativeSource="{RelativeSource AncestorType={x:Type Controls:Panorama}, Mode=FindAncestor}" />
+ <Binding Path="ActualHeight" RelativeSource="{RelativeSource AncestorType={x:Type Controls:Panorama}, Mode=FindAncestor}" />
<Binding Path="ActualHeight" ElementName="header"/>
</MultiBinding>
</WrapPanel.Height>
<WrapPanel.Width>
<MultiBinding Converter="{StaticResource conv}">
<Binding Path="ItemBox" RelativeSource="{RelativeSource AncestorType={x:Type Controls:Panorama}, Mode=FindAncestor}" />
- <!--<Binding Path="GroupHeight" RelativeSource="{RelativeSource AncestorType={x:Type Controls:Panorama}, Mode=FindAncestor}" />-->
<Binding Path="ActualHeight" ElementName="items"/>
<Binding RelativeSource="{RelativeSource AncestorType={x:Type ListBox}, Mode=FindAncestor}" />
+ <Binding Path="Items.Count" ElementName="items"/>
</MultiBinding>
</WrapPanel.Width>
</WrapPanel>
View
16 MetroDemo/MainWindowViewModel.cs
@@ -3,7 +3,6 @@
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Net;
-using System.Windows.Data;
using System.Windows.Threading;
using MahApps.Metro.Controls;
using MetroDemo.Models;
@@ -15,13 +14,17 @@ public class MainWindowViewModel : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
public ObservableCollection<PanoramaGroup> Groups { get; set; }
-
private readonly Dispatcher _dispatcher;
+ readonly PanoramaGroup tracks;
+ readonly PanoramaGroup artists;
public MainWindowViewModel(Dispatcher dispatcher)
{
_dispatcher = dispatcher;
- Groups = new ObservableCollection<PanoramaGroup>();
+ tracks = new PanoramaGroup("trending tracks");
+ artists = new PanoramaGroup("trending artists");
+ Groups = new ObservableCollection<PanoramaGroup> { tracks, artists };
+
var wc = new WebClient();
wc.DownloadStringCompleted += WcDownloadStringCompleted;
wc.DownloadStringAsync(new Uri("http://ws.audioscrobbler.com/2.0/?method=chart.gethypedartists&api_key=b25b959554ed76058ac220b7b2e0a026&format=json"));
@@ -36,7 +39,8 @@ private void WcDownloadStringCompleted2(object sender, DownloadStringCompletedEv
try
{
var x = JsonConvert.DeserializeObject<TrackWrapper>(e.Result);
- _dispatcher.BeginInvoke(new Action(() => Groups.Add(new PanoramaGroup("trending tracks", CollectionViewSource.GetDefaultView(x.Tracks.track.Take(25))))));
+ _dispatcher.BeginInvoke(new Action(() => tracks.SetSource(x.Tracks.track.Take(25))));
+
}
catch (Exception ex)
{
@@ -49,7 +53,8 @@ private void WcDownloadStringCompleted(object sender, DownloadStringCompletedEve
try
{
var x = JsonConvert.DeserializeObject<Wrapper>(e.Result);
- _dispatcher.BeginInvoke(new Action(() => Groups.Add(new PanoramaGroup("trending artists", CollectionViewSource.GetDefaultView(x.Artists.artist.Take(25))))));
+ _dispatcher.BeginInvoke(new Action(() => artists.SetSource(x.Artists.artist.Take(25))));
+
}
catch (Exception ex)
{
@@ -57,6 +62,5 @@ private void WcDownloadStringCompleted(object sender, DownloadStringCompletedEve
}
}
-
}
}
View
21 MetroDemo/PanoramaDemo.xaml
@@ -55,25 +55,6 @@
</RadialGradientBrush>
</Grid.Background>
- <Path Data="M0,0 L40,0 40,330 0,353.5 z" Fill="#26FFFFFF" HorizontalAlignment="Left" Stretch="Fill" Width="40" Height="320.5" VerticalAlignment="Top" />
- <Path Data="M-29,4.3260914E-14 L40,0 40,562 -29,505 z" HorizontalAlignment="Left" Margin="40,0,0,126.5" Stretch="Fill" Width="69" >
- <Path.Fill>
- <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
- <GradientStop Color="#26FFFFFF" Offset="1"/>
- <GradientStop Color="#4CFFFFFF"/>
- </LinearGradientBrush>
- </Path.Fill>
- </Path>
- <Path Data="M0,0 L105,-4 105,189 2.8091949E-15,239 z" HorizontalAlignment="Left" Height="243" Margin="109,-4,0,0" Stretch="Fill" VerticalAlignment="Top" Width="105" >
- <Path.Fill>
- <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
- <GradientStop Color="#26FFFFFF" Offset="0.004"/>
- <GradientStop Color="#4CFFFFFF" Offset="1"/>
- </LinearGradientBrush>
- </Path.Fill>
- </Path>
-
- <!--<Controls:Panorama x:Name="MainPanorama" VerticalAlignment="Stretch" Margin="0,25,25,25" GroupHeight="{Binding ElementName=MainPanorama, Path=ActualHeight}" ItemsSource="{Binding Groups}" />-->
- <Controls:Panorama x:Name="MainPanorama" VerticalAlignment="Stretch" Margin="0,25,25,25" GroupHeight="{Binding ElementName=MainPanorama, Path=ActualHeight}" ItemBox="120" ItemsSource="{Binding Groups}" />
+ <Controls:Panorama x:Name="MainPanorama" VerticalAlignment="Stretch" Margin="0,25,25,25" ItemBox="140" ItemsSource="{Binding Groups}" />
</Grid>
</Window>

No commit comments for this range

Something went wrong with that request. Please try again.