公告:魔扣目录网为广大站长提供免费收录网站服务,提交前请做好本站友链:【 网站目录:https://www.morko.net 】, 免友链快审服务(50元/站),

点击这里在线咨询客服
新站提交
  • 网站:51998
  • 待审:31
  • 小程序:12
  • 文章:1030137
  • 会员:747

今日 10 点,上海,微软中国在 Windows 8 10 月 26 日的全球正式发布前,带我们先睹这全新的系统和硬件的魅力所在!

微软全球 Windows 与 Windows Live 事业部总裁 Steven Sinofsky 和微软全球资深副总裁、大中华区董事长兼首席执行官贺乐赋( Ralph Haupter )共同出席了庆祝活动。

漫长的等待,Win 8 终于快发布了。期待中。。。

下面是我自己学习的Win 8小Sample,为了以后方便学习,特做一些记录。

效果如下图: 右边添加了三个命令,分别为:First Custom Command,Second Custom Command,Third Custom Command。

图1-设置面版

图2-自定义用户控件 右边的控件是用户自己定义的控件,我这里定义的很简单。

关键代码如下:

1、添加命令道设置面版中. 分别添加了三个命令。以及三个命令对应的操作。这里定义的很简单,自己可以定义的更复杂一些。

        private void AddCommandToSettingPanel()
        {
            //Add three command to Setting Panel.
            SettingsCommand cmd1 = new SettingsCommand("1", "First Custom Command",
                c =>
                {
                    SettingPanelUC uc = new SettingPanelUC();
                    uc.Show();
                });
            SettingsCommand cmd2 = new SettingsCommand("2", "Second Custom Command",
                c =>
                {
                    ShowMessageTBK.Text = "Second Custom Command Click";
                });
            SettingsCommand cmd3 = new SettingsCommand("3", "Third Custom Command",
                c =>
                {
                    ShowMessageTBK.Text = "Third Custom Command Click";
                });

            //Add command in CommandsRequested Event.
            SettingsPane.GetForCurrentView().CommandsRequested += (sp, arg) =>
            {
                arg.Request.ApplicationCommands.Add(cmd1);
                arg.Request.ApplicationCommands.Add(cmd2);
                arg.Request.ApplicationCommands.Add(cmd3);
            };
        }


2、显示设置面版

        private void ShowSettingsPanel(object sender, RoutedEventArgs e)
        {
            //Show Setting Panel
            Windows.UI.ApplicationSettings.SettingsPane.Show();
        }


3、自定义控件关键代码:

public sealed partial class SettingPanelUC : UserControl
    {
        Popup pop = null;
        public SettingPanelUC()
        {
            this.InitializeComponent();
            this.Width = 360d;
            this.Height = Window.Current.Bounds.Height;
            this.pop = new Popup();
            this.pop.Child = this;
            this.pop.IsLightDismissEnabled = true;

            //Make the user control is on the right.
            pop.HorizontalOffset = Window.Current.Bounds.Width - this.Width;
            pop.VerticalOffset = 0d;

            //Animation for the user control.
            this.Transitions = new Windows.UI.Xaml.Media.Animation.TransitionCollection();
            EdgeUIThemeTransition et = new EdgeUIThemeTransition();
            et.Edge = EdgeTransitionLocation.Right;
            this.Transitions.Add(et);         
        }

        /// <summary>
        /// 显示控件
        /// </summary>
        public void Show()
        {
            if (pop != null)
            {
                pop.IsOpen = true;
            }
        }

        /// <summary>
        /// 隐藏控件
        /// </summary>
        public void Hide()
        {
            if (pop != null)
            {
                pop.IsOpen = false;
            }
        }

        private void Back(object sender, RoutedEventArgs e)
        {
            this.Hide();
            Windows.UI.ApplicationSettings.SettingsPane.Show();
        }
    }


总结:Win 8 设置面版还是挺简单的,我这里只是学习写了一些简单的东西,并记录下,方便自己以后再次学习。当然,里面的自定义控件的复杂逻辑还是要靠自己去写的。

分享到:
标签:自定义 面版 手工 设置 支持
用户无头像

网友整理

注册时间:

网站:5 个   小程序:0 个  文章:12 篇

  • 51998

    网站

  • 12

    小程序

  • 1030137

    文章

  • 747

    会员

赶快注册账号,推广您的网站吧!
最新入驻小程序

数独大挑战2018-06-03

数独一种数学游戏,玩家需要根据9

答题星2018-06-03

您可以通过答题星轻松地创建试卷

全阶人生考试2018-06-03

各种考试题,题库,初中,高中,大学四六

运动步数有氧达人2018-06-03

记录运动步数,积累氧气值。还可偷

每日养生app2018-06-03

每日养生,天天健康

体育训练成绩评定2018-06-03

通用课目体育训练成绩评定