embedded webbrowser in events and news
This commit is contained in:
@@ -31,17 +31,27 @@
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="100"/>
|
||||
<!--<RowDefinition Height="100"/>-->
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="90"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TextBlock x:Name="EventHeadline" Text="{Binding Path=Title, Mode=OneWay}" Grid.Row="0" Height="Auto" TextWrapping="Wrap" VerticalAlignment="Center" HorizontalAlignment="Left" FontSize="42"/>
|
||||
<ScrollViewer x:Name="EventTextScroll" Grid.Row="1">
|
||||
<TextBlock x:Name="EventText" Text="{Binding Path=Text, Mode=OneWay}" Height="Auto" TextWrapping="Wrap" VerticalAlignment="Center" HorizontalAlignment="Left" FontSize="24" />
|
||||
</ScrollViewer>
|
||||
<Button Name="EventHome" Content="{Binding Path=LocalizedResources.NewsHomeBtn, Source={StaticResource LocalizedStrings}}" Grid.Row="2" VerticalAlignment="Bottom" HorizontalAlignment="Left" Click="EventHome_Click"/>
|
||||
<Button Name="EventLink" Tag="{Binding Path=Link, Mode=OneWay}" Content="{Binding Path=LocalizedResources.NewsLinkBtn, Source={StaticResource LocalizedStrings}}" Grid.Row="2" VerticalAlignment="Bottom" HorizontalAlignment="Right" Click="EventLink_Click"/>
|
||||
<Grid x:Name="EventTextGrid" Grid.Row="0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="100" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TextBlock x:Name="EventHeadline" Text="{Binding Path=Title, Mode=OneWay}" Grid.Row="0" Height="Auto" TextWrapping="Wrap" VerticalAlignment="Center" HorizontalAlignment="Left" FontSize="42"/>
|
||||
<ScrollViewer x:Name="EventTextScroll" Grid.Row="1">
|
||||
<TextBlock x:Name="EventText" Text="{Binding Path=Text, Mode=OneWay}" Height="Auto" TextWrapping="Wrap" VerticalAlignment="Center" HorizontalAlignment="Left" FontSize="24" />
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
|
||||
<phone:WebBrowser x:Name="WebBrowser" Grid.Row="0" IsScriptEnabled="True" Visibility="Collapsed"/>
|
||||
|
||||
<Button Name="EventHome" Content="{Binding Path=LocalizedResources.NewsHomeBtn, Source={StaticResource LocalizedStrings}}" Grid.Row="1" VerticalAlignment="Bottom" HorizontalAlignment="Left" Click="EventHome_Click"/>
|
||||
<Button Name="EventLink" Tag="{Binding Path=Link, Mode=OneWay}" Content="{Binding Path=LocalizedResources.NewsLinkBtn, Source={StaticResource LocalizedStrings}}" Grid.Row="1" VerticalAlignment="Bottom" HorizontalAlignment="Right" Click="EventLink_Click"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</phone:Pivot.ItemTemplate>
|
||||
|
||||
@@ -11,6 +11,7 @@ namespace CampusAppWP8.Pages.Events
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Navigation;
|
||||
using Microsoft.Phone.Controls;
|
||||
using Microsoft.Phone.Tasks;
|
||||
@@ -98,9 +99,37 @@ namespace CampusAppWP8.Pages.Events
|
||||
FrameworkElement fe = sender as FrameworkElement;
|
||||
|
||||
// Open the webbrowser
|
||||
WebBrowserTask webBrowserTask = new WebBrowserTask();
|
||||
webBrowserTask.Uri = new Uri(fe.Tag.ToString(), UriKind.Absolute);
|
||||
webBrowserTask.Show();
|
||||
Grid grfe = fe.Parent as Grid;
|
||||
FrameworkElement eventTextGrid = null;
|
||||
FrameworkElement eventWeb = null;
|
||||
|
||||
foreach (FrameworkElement tempElem in grfe.Children)
|
||||
{
|
||||
if (tempElem.Name == "EventTextGrid")
|
||||
{
|
||||
eventTextGrid = tempElem;
|
||||
}
|
||||
else if (tempElem.Name == "WebBrowser")
|
||||
{
|
||||
eventWeb = tempElem;
|
||||
}
|
||||
}
|
||||
|
||||
if ((eventTextGrid != null)
|
||||
&& (eventWeb != null))
|
||||
{
|
||||
if (eventTextGrid.Visibility == Visibility.Visible)
|
||||
{
|
||||
eventTextGrid.Visibility = Visibility.Collapsed;
|
||||
eventWeb.Visibility = Visibility.Visible;
|
||||
(eventWeb as WebBrowser).Navigate(new Uri(fe.Tag.ToString(), UriKind.Absolute));
|
||||
}
|
||||
else
|
||||
{
|
||||
eventWeb.Visibility = Visibility.Collapsed;
|
||||
eventTextGrid.Visibility = Visibility.Visible;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,17 +31,26 @@
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="100"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="90"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TextBlock x:Name="NewsHeadline" Text="{Binding Path=Title, Mode=OneWay}" Grid.Row="0" Height="Auto" TextWrapping="Wrap" VerticalAlignment="Center" HorizontalAlignment="Left" FontSize="42"/>
|
||||
<ScrollViewer Grid.Row="1">
|
||||
<TextBlock x:Name="NewsText" Text="{Binding Path=Text, Mode=OneWay}" Height="Auto" TextWrapping="Wrap" VerticalAlignment="Center" HorizontalAlignment="Left" FontSize="24" />
|
||||
</ScrollViewer>
|
||||
<Button Name="NewsHome" Content="{Binding Path=LocalizedResources.NewsHomeBtn, Source={StaticResource LocalizedStrings}}" Grid.Row="2" VerticalAlignment="Bottom" HorizontalAlignment="Left" Click="NewsHome_Click"/>
|
||||
<Button Name="NewsLink" Tag="{Binding Path=Link, Mode=OneWay}" Content="{Binding Path=LocalizedResources.NewsLinkBtn, Source={StaticResource LocalizedStrings}}" Grid.Row="2" VerticalAlignment="Bottom" HorizontalAlignment="Right" Click="NewsLink_Click"/>
|
||||
<Grid x:Name="NewsTextGrid" Grid.Row="0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="100" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TextBlock x:Name="NewsHeadline" Text="{Binding Path=Title, Mode=OneWay}" Grid.Row="0" Height="Auto" TextWrapping="Wrap" VerticalAlignment="Center" HorizontalAlignment="Left" FontSize="42"/>
|
||||
<ScrollViewer Grid.Row="1">
|
||||
<TextBlock x:Name="NewsText" Text="{Binding Path=Text, Mode=OneWay}" Height="Auto" TextWrapping="Wrap" VerticalAlignment="Center" HorizontalAlignment="Left" FontSize="24" />
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
|
||||
<phone:WebBrowser x:Name="WebBrowser" Grid.Row="0" IsScriptEnabled="True" Visibility="Collapsed"/>
|
||||
|
||||
<Button Name="NewsHome" Content="{Binding Path=LocalizedResources.NewsHomeBtn, Source={StaticResource LocalizedStrings}}" Grid.Row="1" VerticalAlignment="Bottom" HorizontalAlignment="Left" Click="NewsHome_Click"/>
|
||||
<Button Name="NewsLink" Tag="{Binding Path=Link, Mode=OneWay}" Content="{Binding Path=LocalizedResources.NewsLinkBtn, Source={StaticResource LocalizedStrings}}" Grid.Row="1" VerticalAlignment="Bottom" HorizontalAlignment="Right" Click="NewsLink_Click"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</phone:Pivot.ItemTemplate>
|
||||
|
||||
@@ -11,6 +11,7 @@ namespace CampusAppWP8.Pages.News
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Navigation;
|
||||
using Microsoft.Phone.Controls;
|
||||
using Microsoft.Phone.Tasks;
|
||||
@@ -99,9 +100,37 @@ namespace CampusAppWP8.Pages.News
|
||||
FrameworkElement fe = sender as FrameworkElement;
|
||||
|
||||
// Open the webbrowser
|
||||
WebBrowserTask webBrowserTask = new WebBrowserTask();
|
||||
webBrowserTask.Uri = new Uri(fe.Tag.ToString(), UriKind.Absolute);
|
||||
webBrowserTask.Show();
|
||||
Grid grfe = fe.Parent as Grid;
|
||||
FrameworkElement newsTextGrid = null;
|
||||
FrameworkElement newsWeb = null;
|
||||
|
||||
foreach (FrameworkElement tempElem in grfe.Children)
|
||||
{
|
||||
if (tempElem.Name == "NewsTextGrid")
|
||||
{
|
||||
newsTextGrid = tempElem;
|
||||
}
|
||||
else if (tempElem.Name == "WebBrowser")
|
||||
{
|
||||
newsWeb = tempElem;
|
||||
}
|
||||
}
|
||||
|
||||
if ((newsTextGrid != null)
|
||||
&& (newsWeb != null))
|
||||
{
|
||||
if (newsTextGrid.Visibility == Visibility.Visible)
|
||||
{
|
||||
newsTextGrid.Visibility = Visibility.Collapsed;
|
||||
newsWeb.Visibility = Visibility.Visible;
|
||||
(newsWeb as WebBrowser).Navigate(new Uri(fe.Tag.ToString(), UriKind.Absolute));
|
||||
}
|
||||
else
|
||||
{
|
||||
newsWeb.Visibility = Visibility.Collapsed;
|
||||
newsTextGrid.Visibility = Visibility.Visible;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user