Skip to content

Commit

Permalink
回复话题内任意帖子
Browse files Browse the repository at this point in the history
  • Loading branch information
zcbenz committed Mar 6, 2012
1 parent 5eed9b1 commit 65611ff
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 15 deletions.
12 changes: 1 addition & 11 deletions App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:local="clr-namespace:sbbs_client_wp7"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:sys="clr-namespace:System;assembly=mscorlib">
Expand Down Expand Up @@ -64,17 +65,6 @@
</Grid>
</DataTemplate>

<!--话题内容Template-->
<DataTemplate x:Key="ContentDataTemplate">
<StackPanel>
<Grid Margin="-12 0 0 0">
<TextBlock Style="{StaticResource PhoneTextAccentStyle}" Text="{Binding Author}"/>
<TextBlock HorizontalAlignment="Right" Text="{Binding Time, Converter={StaticResource StampDateConverter}}"/>
</Grid>
<TextBlock Text="{Binding Content}" TextWrapping="Wrap" FontSize="{StaticResource PhoneFontSizeMedium}" Margin="0 0 0 12"/>
</StackPanel>
</DataTemplate>

<!--版面列表Template-->
<DataTemplate x:Key="BoardDataTemplate">
<Grid Margin="0 0 0 10">
Expand Down
22 changes: 21 additions & 1 deletion TopicPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,26 @@
</toolkit:NavigationOutTransition.Forward>
</toolkit:NavigationOutTransition>
</toolkit:TransitionService.NavigationOutTransition>

<phone:PhoneApplicationPage.Resources>
<!--话题内容Template-->
<DataTemplate x:Key="ContentDataTemplate">
<StackPanel>
<toolkit:ContextMenuService.ContextMenu>
<toolkit:ContextMenu>
<toolkit:MenuItem Header="回复" Click="MenuReply_Click"/>
<toolkit:MenuItem Header="发送站内信"/>
<toolkit:MenuItem Header="查询用户"/>
</toolkit:ContextMenu>
</toolkit:ContextMenuService.ContextMenu>
<Grid Margin="-12 0 0 0">
<TextBlock Style="{StaticResource PhoneTextAccentStyle}" Text="{Binding Author}"/>
<TextBlock HorizontalAlignment="Right" Text="{Binding Time, Converter={StaticResource StampDateConverter}}"/>
</Grid>
<TextBlock Text="{Binding Content}" TextWrapping="Wrap" FontSize="{StaticResource PhoneFontSizeMedium}" Margin="0 0 0 12"/>
</StackPanel>
</DataTemplate>
</phone:PhoneApplicationPage.Resources>

<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
Expand All @@ -60,7 +80,7 @@

<ScrollViewer Grid.Row="1" Margin="12,0,12,0">
<StackPanel>
<ListBox ItemsSource="{Binding Topics}" ItemTemplate="{StaticResource ContentDataTemplate}"
<ListBox x:Name="TopicsList" ItemsSource="{Binding Topics}" ItemTemplate="{StaticResource ContentDataTemplate}"
ScrollViewer.VerticalScrollBarVisibility="Disabled"
SelectionChanged="ListBox_SelectionChanged">
<ListBox.ItemContainerStyle>
Expand Down
16 changes: 13 additions & 3 deletions TopicPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,18 @@ private void Refresh_Click(object sender, EventArgs e)

private void Reply_Click(object sender, EventArgs e)
{
NavigationService.Navigate(new Uri("/PostPage.xaml?title=" + HttpUtility.UrlEncode(App.ViewModel.CurrentTopic.Title) + "&board=" + App.ViewModel.CurrentTopic.Board
+ "&reid=" + App.ViewModel.CurrentTopic.Id, UriKind.Relative));
TopicViewModel topic = TopicsList.SelectedItem as TopicViewModel;
if (topic == null)
NavigationService.Navigate(new Uri("/PostPage.xaml?title=" + HttpUtility.UrlEncode(App.ViewModel.CurrentTopic.Title) + "&board=" + App.ViewModel.CurrentTopic.Board
+ "&reid=" + App.ViewModel.CurrentTopic.Id, UriKind.Relative));
else
NavigationService.Navigate(new Uri("/PostPage.xaml?title=" + HttpUtility.UrlEncode(topic.Title) + "&board=" + topic.Board + "&reid=" + topic.Id, UriKind.Relative));
}

private void MenuReply_Click(object sender, EventArgs e)
{
TopicViewModel topic = (sender as MenuItem).DataContext as TopicViewModel;
NavigationService.Navigate(new Uri("/PostPage.xaml?title=" + HttpUtility.UrlEncode(topic.Title) + "&board=" + topic.Board + "&reid=" + topic.Id, UriKind.Relative));
}

private void LoadTopics()
Expand Down Expand Up @@ -126,7 +136,7 @@ private void LoadTopics()

private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if ((sender as ListBox).SelectedIndex != -1)
if ((sender as ListBox).SelectedIndex == 0)
(sender as ListBox).SelectedIndex = -1;
}
}
Expand Down

0 comments on commit 65611ff

Please sign in to comment.