This commit is contained in:
stubbfel
2013-07-01 13:19:07 +02:00
parent 5a55355f98
commit d8071e76eb
3 changed files with 68 additions and 72 deletions

View File

@@ -18,7 +18,7 @@
<Border Background="{x:Null}" BorderBrush="{StaticResource PhoneInverseInactiveBrush}" BorderThickness="0,1,0,0" Padding="0,0,0,0">
<StackPanel>
<Button Click="ToggleOptions" BorderBrush="{x:Null}">
<Button Click="ToggleOptions" Background="Gray" BorderBrush="Gray" Foreground="Black" Margin="-10,-10,-10,-10" >
<Grid>
<Grid.RowDefinitions>
@@ -60,9 +60,49 @@
<!--ContentPanel - zusätzliche Inhalte hier platzieren-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<ScrollViewer>
<phone:LongListSelector Name="ResultList" ItemTemplate="{StaticResource LectureItemTemplate}" HorizontalContentAlignment="Left" />
</ScrollViewer>
<!--<phone:LongListSelector Name="ResultList" ItemTemplate="{StaticResource LectureItemTemplate}" HorizontalContentAlignment="Left" /> -->
<ListBox x:Name="ResultList" Grid.Row="1">
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="HorizontalAlignment" Value="Stretch"/>
</Style>
</ListBox.ItemContainerStyle>
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<Button Click="ToggleOptions" Background="Gray" BorderBrush="Gray" Foreground="Black" Margin="-10,-10,-10,-10" >
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding Type}" Grid.Column="0" Grid.Row="0"/>
<TextBlock Text=" : " Grid.Column="1" Grid.Row="0"/>
<TextBlock Text="{Binding Title}" TextWrapping="Wrap" Grid.Column="2" Grid.Row="0"/>
</Grid>
</Button>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Visibility="Collapsed">
<Button Name="Link" Content="Link" Tag="{Binding Modul.Number}" Click="ShowModulWebPage"/>
<Button Name="Details" Content="Details" Tag="{Binding Id}" Click="ShowDetailPage"/>
</StackPanel>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</Grid>

View File

@@ -8,6 +8,7 @@
namespace CampusAppWP8.Pages.Lecture
{
using System;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
@@ -20,6 +21,12 @@ namespace CampusAppWP8.Pages.Lecture
/// </summary>
public partial class ResultPage : PhoneApplicationPage
{
/// <summary>
/// last visible UI element.
/// </summary>
private UIElement lastOpenUIElem = null;
/// <summary>
/// Initializes a new instance of the <see cref="ResultPage" /> class.
/// </summary>
@@ -43,7 +50,7 @@ namespace CampusAppWP8.Pages.Lecture
}
this.ResultList.ItemsSource = list.Activities;
base.OnNavigatedTo(e);
base.OnNavigatedTo(e);
}
/// <summary>
@@ -53,78 +60,29 @@ namespace CampusAppWP8.Pages.Lecture
/// <param name="e">some EventArgs</param>
private void ToggleOptions(object sender, RoutedEventArgs e)
{
Button button = (Button)sender;
StackPanel parent = (StackPanel)button.Parent;
Button link = (Button)parent.FindName("Link");
Button details = (Button)parent.FindName("Details");
if (link.Tag == null)
if (this.lastOpenUIElem != null)
{
link.IsEnabled = false;
this.lastOpenUIElem.Visibility = Visibility.Collapsed;
}
this.ToogleVisibility(link);
this.ToogleVisibility(details);
}
FrameworkElement btn = sender as FrameworkElement;
StackPanel parent = btn.Parent as StackPanel;
/// <summary>
/// Method shows the Link- and Details-Buttons
/// </summary>
/// <param name="parent">Reference of the StackPanel which include the buttons </param>
private void ShowOptions(StackPanel parent)
{
Button link = (Button)parent.FindName("Link");
Button details = (Button)parent.FindName("Details");
this.ShowVisibility(link);
this.ShowVisibility(details);
}
/// <summary>
/// Method hide the Link- and Details-Buttons
/// </summary>
/// <param name="parent">Reference of the StackPanel which include the buttons </param>
private void HideOptions(StackPanel parent)
{
UIElement link = (UIElement)parent.FindName("Link");
UIElement details = (UIElement)parent.FindName("Details");
this.HideVisibility(link);
this.HideVisibility(details);
}
/// <summary>
/// Method toggle the Visibility of an UIElement
/// </summary>
/// <param name="element">UIElement which Visibility has to be toggle</param>
private void ToogleVisibility(UIElement element)
{
if (System.Windows.Visibility.Visible.Equals(element.Visibility))
if (parent.Children.Count() >= 2)
{
this.HideVisibility(element);
}
else
{
this.ShowVisibility(element);
if (!parent.Children[1].Equals(this.lastOpenUIElem))
{
this.lastOpenUIElem = parent.Children[1];
this.lastOpenUIElem.Visibility = Visibility.Visible;
}
else
{
this.lastOpenUIElem = null;
}
}
}
/// <summary>
/// Method set the Visibility=true of an UIElement
/// </summary>
/// <param name="element">UIElement which Visibility has to been true</param>
private void ShowVisibility(UIElement element)
{
element.Visibility = System.Windows.Visibility.Visible;
}
/// <summary>
/// Method set the Visibility=false of an UIElement
/// </summary>
/// <param name="element">UIElement which Visibility has to been false</param>
private void HideVisibility(UIElement element)
{
element.Visibility = System.Windows.Visibility.Collapsed;
}
/// <summary>
/// Method navigate to ModuleWebPage
/// </summary>
@@ -133,7 +91,6 @@ namespace CampusAppWP8.Pages.Lecture
private void ShowModulWebPage(object sender, RoutedEventArgs e)
{
Button btn = (Button)sender;
HideOptions((StackPanel)btn.Parent);
Uri url = new Uri(Constants.PathLecture_ModulWebPage + "?" + Constants.ParamModelLecture_ModulNumber + "=" + btn.Tag, UriKind.Relative);
NavigationService.Navigate(url);
}
@@ -146,7 +103,6 @@ namespace CampusAppWP8.Pages.Lecture
private void ShowDetailPage(object sender, RoutedEventArgs e)
{
Button btn = (Button)sender;
HideOptions((StackPanel)btn.Parent);
Uri url = new Uri(Constants.PathLecture_ResultDetailPage + "?" + Constants.ParamModelLecture_ActivityId + "=" + btn.Tag, UriKind.Relative);
NavigationService.Navigate(url);
}

View File

@@ -117,7 +117,7 @@ namespace CampusAppWP8.Pages.Openinghours
FrameworkElement btn = sender as FrameworkElement;
StackPanel parent = btn.Parent as StackPanel;
parent.Children.Count();
if (parent.Children.Count() >= 2)
{
if (this.lastOpenUIElem != parent.Children[1])