wpf 实现类似QQ音乐点击按钮动态加载页面的效能
wpf 实现类似QQ音乐点击按钮动态加载页面的功能

就是点击“推荐”、“排行榜”等按钮就会动态加载相应页面(之前我做了一个标签页的功能来模仿,但是同事说这个是使用点击button动态加载来实现的)。
暂时有问题2:
1、这个动态加载怎么实现的,代码写在后台要怎么写,请给些简单实例
2、动态加载后,之前那个页面是被清空了还是被覆盖了?比如:先后点击“推荐”、“排行榜”按钮,最后在用户面前的是“排行榜”页面,那之前的“推荐”页面去哪了呢?
菜鸟求帮助!!
------解决思路----------------------


------解决思路----------------------
我觉得这是个TabControl吧
------解决思路----------------------
用TabControl或者ContentControl切换都可以;至于动态加载,搞个 进度条都行了;
------解决思路----------------------
动态加载就是根据你点击的图标生成页面,可以使用TabControl,把生成的新页面全部放到TabControl中,以前的页不会被覆盖。还可以不用TabControl,直接把前面的页移除,然后加上新的页。后者比较简单,占用资源略少,前者打开重复的页面时不需要加载,省了加载页面的时间。
------解决思路----------------------
没使用TabControl
前端
后端
就是点击“推荐”、“排行榜”等按钮就会动态加载相应页面(之前我做了一个标签页的功能来模仿,但是同事说这个是使用点击button动态加载来实现的)。
暂时有问题2:
1、这个动态加载怎么实现的,代码写在后台要怎么写,请给些简单实例
2、动态加载后,之前那个页面是被清空了还是被覆盖了?比如:先后点击“推荐”、“排行榜”按钮,最后在用户面前的是“排行榜”页面,那之前的“推荐”页面去哪了呢?
菜鸟求帮助!!
------解决思路----------------------
------解决思路----------------------
我觉得这是个TabControl吧
------解决思路----------------------
用TabControl或者ContentControl切换都可以;至于动态加载,搞个 进度条都行了;
------解决思路----------------------
动态加载就是根据你点击的图标生成页面,可以使用TabControl,把生成的新页面全部放到TabControl中,以前的页不会被覆盖。还可以不用TabControl,直接把前面的页移除,然后加上新的页。后者比较简单,占用资源略少,前者打开重复的页面时不需要加载,省了加载页面的时间。
------解决思路----------------------
没使用TabControl
前端
<Window x:Class="WpfApplication2.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="600" Width="800">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal">
<Button Name="button1" Content="推荐" Width="100" Height="30" />
<Button Name="button2" Content="排行榜" Width="100" Height="30" />
<Button Name="button3" Content="歌单广场" Width="100" Height="30" />
</StackPanel>
<Grid Name="grid1" Grid.Row="1">
</Grid>
</Grid>
</Window>
后端
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
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;
using System.Collections.ObjectModel;
namespace WpfApplication2
{
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
button1.Click += new RoutedEventHandler(button1_Click);
button2.Click += new RoutedEventHandler(button2_Click);
button3.Click += new RoutedEventHandler(button3_Click);
}
void button1_Click(object sender, RoutedEventArgs e)
{
grid1.Children.Clear();
Frame frame = new Frame();
grid1.Children.Add(frame);
try
{
frame.Navigate(new Uri("Page1.xaml", UriKind.RelativeOrAbsolute)); //Page1.xaml 为页面名称 下同
}
catch
{
MessageBox.Show("该页面不存在");
}
}
void button2_Click(object sender, RoutedEventArgs e)
{