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样式全部删除,瞬间提速。

转载于:https://www.cnblogs.com/lzhangxiaohupi/p/10749952.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值