wpf1

emCombobox.Items[2].IsEnabled = false;

隐藏下拉框里面的一个item

 

wpf 单例模式。

[DllImport("user32", CharSet = CharSet.Unicode)]
        static extern IntPtr FindWindow(string cls, string win);
        [DllImport("user32")]
        static extern IntPtr SetForegroundWindow(IntPtr hWnd);
        [DllImport("user32")]
        static extern bool IsIconic(IntPtr hWnd);
        [DllImport("user32")]
        static extern bool OpenIcon(IntPtr hWnd);

        protected override void OnStartup(StartupEventArgs e)
        {
            bool isNew;
            var mutex = new Mutex(true, "My Singleton Instance", out isNew);
            if (!isNew)
            {
                ActivateOtherWindow();
                Shutdown();
            }
        }
        private static void ActivateOtherWindow()
        {
            var other = FindWindow(null, "MainWindow");
            if (other != IntPtr.Zero)
            {
                SetForegroundWindow(other);
                if (IsIconic(other))
                    OpenIcon(other);
            }
        }

 

 

今天解决了一个搞了很久的问题。wpf中的datagrid画面渲染慢的问题。

差了很多资料,发现都不好用。

看别人的sample,发现刷新很快,然后就去找源码,跟着写一个画面。

还是很慢。

然后独立建立了一个工程,把刚才的window移动到新建的项目里面,发现速度变快了。

对现有开发工程,启动项目进行修改,逐一排查。

终于发现,是在app.xaml里面加入了很多没用的样式,每个工程的样式都在这加进去了。

app.xaml样式全部删除,瞬间提速。

posted @ 2019-04-22 14:32  旺仔小虎屁  阅读(136)  评论(0编辑  收藏  举报