框架优化
This commit is contained in:
@@ -15,208 +15,5 @@
|
||||
<converters:BooleanToVisibilityConverter x:Key="BoolToVis" />
|
||||
</UserControl.Resources>
|
||||
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<!-- 搜索栏区域 -->
|
||||
<RowDefinition Height="Auto"/>
|
||||
<!-- 标签分类区域 -->
|
||||
<RowDefinition Height="Auto"/>
|
||||
<!-- 内容区域 -->
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- 顶部搜索栏 -->
|
||||
<Border Grid.Row="0" Background="#F5F5F5" Padding="20,15">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!-- 搜索框 -->
|
||||
<TextBox Grid.Column="0"
|
||||
Margin="0,0,10,0"
|
||||
Style="{StaticResource MaterialDesignOutlinedTextBox}"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="16"
|
||||
Height="40"
|
||||
materialDesign:HintAssist.Hint="搜索帖子..."
|
||||
Text="{Binding SearchKeyword, UpdateSourceTrigger=PropertyChanged}"
|
||||
KeyDown="SearchBox_KeyDown"/>
|
||||
|
||||
<!-- 消息通知按钮 -->
|
||||
<Button Grid.Column="1"
|
||||
Margin="0,0,10,0"
|
||||
Style="{StaticResource MaterialDesignFloatingActionMiniDarkButton}"
|
||||
ToolTip="消息通知">
|
||||
<materialDesign:PackIcon Kind="BellOutline" Height="24" Width="24" />
|
||||
</Button>
|
||||
|
||||
<!-- 发帖按钮 -->
|
||||
<Button Grid.Column="2"
|
||||
Content="发布帖子"
|
||||
Style="{StaticResource MaterialDesignRaisedLightButton}"
|
||||
Background="#FF2196F3"
|
||||
Foreground="White"
|
||||
FontSize="14"
|
||||
FontWeight="Medium"
|
||||
Height="40"
|
||||
Width="100"
|
||||
Command="{Binding CreatePostCommand}"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
<!-- 标签分类区域 -->
|
||||
<Border Grid.Row="1" Background="White" Padding="20,10" BorderBrush="#E0E0E0" BorderThickness="0,0,0,1">
|
||||
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Disabled">
|
||||
<StackPanel Orientation="Horizontal" >
|
||||
<Button Content="全部"
|
||||
Style="{StaticResource MaterialDesignFlatButton}"
|
||||
Background="#FF2196F3"
|
||||
Foreground="White"
|
||||
Command="{Binding CategorySelectCommand}"
|
||||
CommandParameter="全部"/>
|
||||
<Button Content="热门"
|
||||
Style="{StaticResource MaterialDesignFlatButton}"
|
||||
Background="#FF9800"
|
||||
Foreground="White"
|
||||
Command="{Binding CategorySelectCommand}"
|
||||
CommandParameter="热门"/>
|
||||
<Button Content="科技"
|
||||
Style="{StaticResource MaterialDesignFlatButton}"
|
||||
Background="#4CAF50"
|
||||
Foreground="White"
|
||||
Command="{Binding CategorySelectCommand}"
|
||||
CommandParameter="科技"/>
|
||||
<Button Content="生活"
|
||||
Style="{StaticResource MaterialDesignFlatButton}"
|
||||
Background="#9C27B0"
|
||||
Foreground="White"
|
||||
Command="{Binding CategorySelectCommand}"
|
||||
CommandParameter="生活"/>
|
||||
<Button Content="娱乐"
|
||||
Style="{StaticResource MaterialDesignFlatButton}"
|
||||
Background="#E91E63"
|
||||
Foreground="White"
|
||||
Command="{Binding CategorySelectCommand}"
|
||||
CommandParameter="娱乐"/>
|
||||
<Button Content="游戏"
|
||||
Style="{StaticResource MaterialDesignFlatButton}"
|
||||
Background="#795548"
|
||||
Foreground="White"
|
||||
Command="{Binding CategorySelectCommand}"
|
||||
CommandParameter="游戏"/>
|
||||
<Button Content="学习"
|
||||
Style="{StaticResource MaterialDesignFlatButton}"
|
||||
Background="#009688"
|
||||
Foreground="White"
|
||||
Command="{Binding CategorySelectCommand}"
|
||||
CommandParameter="学习"/>
|
||||
<Button Content="美食"
|
||||
Style="{StaticResource MaterialDesignFlatButton}"
|
||||
Background="#FF5722"
|
||||
Foreground="White"
|
||||
Command="{Binding CategorySelectCommand}"
|
||||
CommandParameter="美食"/>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</Border>
|
||||
|
||||
<!-- 推荐帖子列表 -->
|
||||
<ScrollViewer Grid.Row="2" VerticalScrollBarVisibility="Auto">
|
||||
<ItemsControl ItemsSource="{Binding Posts}" Margin="20,15,20,20">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Border Background="White"
|
||||
Margin="0,0,0,15"
|
||||
CornerRadius="8"
|
||||
BorderBrush="#E0E0E0"
|
||||
BorderThickness="1"
|
||||
Effect="{DynamicResource MaterialDesignShadowDepth1}">
|
||||
<Grid Margin="15">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- 帖子头部信息 -->
|
||||
<Grid Grid.Row="0" Margin="0,0,0,10">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!-- 用户头像占位 -->
|
||||
<Ellipse Grid.Column="0"
|
||||
Width="40"
|
||||
Height="40"
|
||||
Fill="#BDBDBD"
|
||||
VerticalAlignment="Center"/>
|
||||
|
||||
<StackPanel Grid.Column="1" Margin="10,0,0,0" VerticalAlignment="Center">
|
||||
<TextBlock Text="{Binding AuthorName}"
|
||||
FontSize="14"
|
||||
FontWeight="Medium"
|
||||
Foreground="#212121"/>
|
||||
<TextBlock Text="{Binding PublishTime, StringFormat=\{0:MM-dd HH:mm\}}"
|
||||
FontSize="12"
|
||||
Foreground="#757575"
|
||||
Margin="0,2,0,0"/>
|
||||
</StackPanel>
|
||||
|
||||
<!-- 置顶或精华标识 -->
|
||||
<StackPanel Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Right" >
|
||||
<Border Background="#FF9800" Padding="6,2" CornerRadius="3" Visibility="{Binding IsEssence, Converter={StaticResource BoolToVis}}">
|
||||
<TextBlock Text="精" FontSize="12" Foreground="White" FontWeight="Bold"/>
|
||||
</Border>
|
||||
<Border Background="#2196F3" Padding="6,2" CornerRadius="3" Visibility="{Binding IsTop, Converter={StaticResource BoolToVis}}">
|
||||
<TextBlock Text="顶" FontSize="12" Foreground="White" FontWeight="Bold"/>
|
||||
</Border>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
<!-- 帖子标题和内容 -->
|
||||
<StackPanel Grid.Row="1" Margin="0,0,0,10">
|
||||
<TextBlock Text="{Binding Title}"
|
||||
FontSize="16"
|
||||
FontWeight="SemiBold"
|
||||
Foreground="#212121"
|
||||
TextWrapping="Wrap"
|
||||
Margin="0,0,0,5"/>
|
||||
<TextBlock Text="{Binding Content}"
|
||||
FontSize="14"
|
||||
Foreground="#424242"
|
||||
TextWrapping="Wrap"
|
||||
MaxHeight="60"
|
||||
TextTrimming="CharacterEllipsis"/>
|
||||
</StackPanel>
|
||||
|
||||
<!-- 帖子底部统计信息 -->
|
||||
<Grid Grid.Row="2">
|
||||
<StackPanel Orientation="Horizontal" >
|
||||
<StackPanel Orientation="Horizontal" >
|
||||
<materialDesign:PackIcon Kind="Eye" Height="16" Width="16" Foreground="#757575"/>
|
||||
<TextBlock Text="{Binding ViewCount}" Foreground="#757575" FontSize="12"/>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<materialDesign:PackIcon Kind="ThumbUpOutline" Height="16" Width="16" Foreground="#757575"/>
|
||||
<TextBlock Text="{Binding LikeCount}" Foreground="#757575" FontSize="12"/>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<materialDesign:PackIcon Kind="CommentOutline" Height="16" Width="16" Foreground="#757575"/>
|
||||
<TextBlock Text="{Binding CommentCount}" Foreground="#757575" FontSize="12"/>
|
||||
</StackPanel>
|
||||
<TextBlock Text="{Binding Category}" Foreground="#2196F3" FontSize="12" VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
|
||||
</UserControl>
|
||||
|
||||
@@ -25,16 +25,6 @@ namespace MainModule.Views
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void SearchBox_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Key.Enter)
|
||||
{
|
||||
// 触发搜索命令
|
||||
if (DataContext is ViewModels.MainViewModel viewModel)
|
||||
{
|
||||
viewModel.SearchCommand?.Execute(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,108 +0,0 @@
|
||||
<UserControl x:Class="MainModule.Views.PostDetailView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:converters="clr-namespace:UIShare.Converters;assembly=UIShare"
|
||||
mc:Ignorable="d"
|
||||
xmlns:prism="http://prismlibrary.com/"
|
||||
prism:ViewModelLocator.AutoWireViewModel="True"
|
||||
d:DesignHeight="800"
|
||||
d:DesignWidth="1000">
|
||||
<UserControl.Resources>
|
||||
<converters:BooleanToVisibilityConverter x:Key="BoolToVis" />
|
||||
</UserControl.Resources>
|
||||
|
||||
<Grid Margin="20">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- 帖子头部信息 -->
|
||||
<Border Grid.Row="0" Background="White" CornerRadius="8" BorderBrush="#E0E0E0" BorderThickness="1" Padding="20">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Ellipse Grid.Column="0" Width="50" Height="50" Fill="#BDBDBD" VerticalAlignment="Center"/>
|
||||
|
||||
<StackPanel Grid.Column="1" Margin="15,0,0,0" VerticalAlignment="Center">
|
||||
<TextBlock Text="{Binding SelectedPost.AuthorName}" FontSize="16" FontWeight="Medium" Foreground="#212121"/>
|
||||
<TextBlock Text="{Binding SelectedPost.PublishTime, StringFormat=\\{0:yyyy-MM-dd HH:mm:ss\\}}" FontSize="12" Foreground="#757575" Margin="0,2,0,0"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Right" >
|
||||
<Border Background="#FF9800" Padding="8,4" CornerRadius="4" Visibility="{Binding SelectedPost.IsEssence, Converter={StaticResource BoolToVis}}">
|
||||
<TextBlock Text="精" FontSize="12" Foreground="White" FontWeight="Bold"/>
|
||||
</Border>
|
||||
<Border Background="#2196F3" Padding="8,4" CornerRadius="4" Visibility="{Binding SelectedPost.IsTop, Converter={StaticResource BoolToVis}}">
|
||||
<TextBlock Text="顶" FontSize="12" Foreground="White" FontWeight="Bold"/>
|
||||
</Border>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
<!-- 帖子内容区域 -->
|
||||
<Border Grid.Row="1" Background="White" CornerRadius="8" BorderBrush="#E0E0E0" BorderThickness="1" Margin="0,10,0,10" Padding="20">
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto">
|
||||
<StackPanel>
|
||||
<TextBlock Text="{Binding SelectedPost.Title}" FontSize="24" FontWeight="Bold" Foreground="#212121" Margin="0,0,0,20"/>
|
||||
<TextBlock Text="{Binding SelectedPost.Content}" FontSize="16" Foreground="#424242" TextWrapping="Wrap" LineHeight="28"/>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</Border>
|
||||
|
||||
<!-- 统计信息和操作区域 -->
|
||||
<Border Grid.Row="2" Background="White" CornerRadius="8" BorderBrush="#E0E0E0" BorderThickness="1" Padding="20">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<StackPanel Grid.Column="0" Orientation="Horizontal" >
|
||||
<StackPanel Orientation="Horizontal" >
|
||||
<materialDesign:PackIcon Kind="Eye" Height="20" Width="20" Foreground="#757575"/>
|
||||
<TextBlock Text="{Binding SelectedPost.ViewCount}" Foreground="#757575" FontSize="14"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal" >
|
||||
<materialDesign:PackIcon Kind="ThumbUpOutline" Height="20" Width="20" Foreground="#757575"/>
|
||||
<TextBlock Text="{Binding SelectedPost.LikeCount}" Foreground="#757575" FontSize="14"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal" >
|
||||
<materialDesign:PackIcon Kind="CommentOutline" Height="20" Width="20" Foreground="#757575"/>
|
||||
<TextBlock Text="{Binding SelectedPost.CommentCount}" Foreground="#757575" FontSize="14"/>
|
||||
</StackPanel>
|
||||
|
||||
<TextBlock Text="{Binding SelectedPost.Category}" Foreground="#2196F3" FontSize="14" FontWeight="Medium" VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Grid.Column="1" Orientation="Horizontal">
|
||||
<Button Content="点赞"
|
||||
Style="{StaticResource MaterialDesignRaisedLightButton}"
|
||||
Background="#4CAF50"
|
||||
Foreground="White"
|
||||
Command="{Binding LikePostCommand}"/>
|
||||
<Button Content="收藏"
|
||||
Style="{StaticResource MaterialDesignRaisedLightButton}"
|
||||
Background="#FF9800"
|
||||
Foreground="White"
|
||||
Command="{Binding FavoritePostCommand}"/>
|
||||
<Button Content="分享"
|
||||
Style="{StaticResource MaterialDesignRaisedLightButton}"
|
||||
Background="#2196F3"
|
||||
Foreground="White"
|
||||
Command="{Binding SharePostCommand}"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -1,28 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace MainModule.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// PostDetailView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class PostDetailView : UserControl
|
||||
{
|
||||
public PostDetailView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user