如何调整WPF关于Box的大小

时间:2013-09-02 08:28:28

标签: c# wpf wpf-controls

我试图在我的WPF应用程序http://www.nuget.org/packages/AboutBox/中使用有关bopx的内容 但我无法弄清楚如何调整它以及如何使它不可拖动。我试过了,但没办法:

            About about = new About();
            about.Window.Width = 120;
            about.Window.Height = 130;
            about.Window.MaxWidth = 120;
            about.Window.MaxHeight = 130;
            about.Window.MinWidth = 120;
            about.Window.MinHeight = 130;
            about.Window.ResizeMode = ResizeMode.NoResize;
            about.Window.WindowStyle = WindowStyle.ToolWindow;
            about.Window.WindowState = WindowState.Minimized;
            about.Window.AllowDrop = false;
            about.Show();
可能有些人可能有所帮助。 此外,我想显示关闭或确定按钮关闭窗口,并希望在焦点失去时禁用关闭窗口。

更新 我最终使用http://wpfmbx.codeplex.com/,这正是我需要的

1 个答案:

答案 0 :(得分:1)

我没有尝试过关于框,但是以下应该是正确的高度顺序:

        About about = new About();
        about.Window.MinWidth = 120;
        about.Window.MinHeight = 130;
        about.Window.MaxWidth = 120;
        about.Window.MaxHeight = 130;
        about.Window.Width = 120;
        about.Window.Height = 130;

MinWidth / MinHeight优先于MaxWidth / MaxHeight和Width / Height。我不是100%确定这是你问题的原因,只是试一试。

为了能够手动拖动,你只需要在MouseDown或类似的事件上调用DragMove()。