我要在我的程序中添加一个WPF Ribbon UI.
根据您的经验,什么是最好的WPF控件套件,包括功能区控件?
谢谢!
我已将主窗口状态设置为"最大化",但问题是我的应用程序将填满整个屏幕甚至任务栏.我究竟做错了什么 ?我正在使用分辨率为1600*900的Windows 2008 R2
这是Xaml:
<Window x:Class="RadinFarazJamAutomationSystem.wndMain"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:local="clr-namespace:RadinFarazJamAutomationSystem"
xmlns:mwt="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero"
Title="MyName" FontFamily="Tahoma" FontSize="12" Name="mainWindow" WindowState="Maximized" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
xmlns:my="clr-namespace:RadinFarazJamAutomationSystem.Calendare.UC" mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" Loaded="mainWindow_Loaded" FlowDirection="LeftToRight"
ResizeMode="NoResize" Closed="mainWindow_Closed">
Run Code Online (Sandbox Code Playgroud) 我使用WindowChrome来自定义Window.当我最大化窗口时,边缘不在屏幕上.我使用以下代码来解决此问题:
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<WindowChrome.WindowChrome>
<WindowChrome CaptionHeight="50" CornerRadius="0" GlassFrameThickness="0" NonClientFrameEdges="None" ResizeBorderThickness="5" UseAeroCaptionButtons="False" />
</WindowChrome.WindowChrome>
<Grid>
<Grid.Style>
<Style TargetType="{x:Type Grid}">
<Setter Property="Margin" Value="0" />
<Style.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=WindowState}" Value="Maximized">
<Setter Property="Margin" Value="{x:Static SystemParameters.WindowResizeBorderThickness}" />
</DataTrigger>
</Style.Triggers>
</Style>
</Grid.Style>
<Border BorderThickness="2" BorderBrush="Blue" Background="Yellow" />
</Grid>
</Window>
Run Code Online (Sandbox Code Playgroud)
我的问题:如何获得正确的像素数,以便边缘不在屏幕之外.
SystemParameters.WindowResizeBorderThickness包含的值不正确.
我在创建设置大小的客户区时遇到了一些问题.AdjustWindowRect()将无法正常工作,所以我决定尝试手动计算窗口的宽度和高度.
这也不起作用,我想知道为什么所以我检查了我以前考虑边界等的值.
#include <iostream>
#include <Windows.h>
int main(void)
{
std::cout << "GetSystemMetrics(SM_CYEDGE) = " << GetSystemMetrics(SM_CYEDGE) << std::endl;
std::cout << "GetSystemMetrics(SM_CXEDGE) = " << GetSystemMetrics(SM_CXEDGE) << std::endl;
std::cout << "GetSystemMetrics(SM_CYBORDER) = " << GetSystemMetrics(SM_CYBORDER) << std::endl;
std::cout << "GetSystemMetrics(SM_CXBORDER) = " << GetSystemMetrics(SM_CXBORDER) << std::endl;
std::cout << "GetSystemMetrics(SM_CYCAPTION) = " << GetSystemMetrics(SM_CYCAPTION);
std::cin.get();
}
Run Code Online (Sandbox Code Playgroud)
这给了我:
GetSystemMetrics(SM_CYEDGE) = 2
GetSystemMetrics(SM_CXEDGE) = 2
GetSystemMetrics(SM_CYBORDER) = 1
GetSystemMetrics(SM_CXBORDER) = 1
GetSystemMetrics(SM_CYCAPTION) = 22
Run Code Online (Sandbox Code Playgroud)
我很确定窗户的边框不是那么薄.我究竟做错了什么?
编辑1:
最初我的窗口使用了WS_OVERLAPPED样式.由于AdjustWindowRect不允许将该样式与它一起使用,因此我构造了我想要的相同类型的窗口:(WS_BORDER | WS_CAPTION | WS_SYSMENU).这是我在调用AdjustWindowRect和AdjustWindowRectEx时使用的相同样式(这个样式以NULL作为扩展样式,因为我不使用任何样式).这给了我正确的宽度,但高度缺少几个像素.
RECT rect = …Run Code Online (Sandbox Code Playgroud) 我正在将该System.Windows.Controls.Ribbon库用于我的应用程序.一切都工作得非常好,除非我最大化窗口它开始离开屏幕.
我也注意到使用其他WPF应用程序但是当你使用RibbonWindow它时会变得更糟.

这是我的源代码(我认为没什么好激动的):
<RibbonWindow
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="WpfApplication1.MainWindow"
Title="TestWindow" Height="350" Width="525" Background="LightSteelBlue">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Ribbon Grid.Row="0">
<RibbonTab x:Name="TestRibbon" Header="TestRibbon">
<RibbonGroup>
<RibbonButton x:Name="TestButton" Label="Button" LargeImageSource="traffic_lights_green.png" />
</RibbonGroup>
</RibbonTab>
</Ribbon>
<ContentControl Grid.Row="1">
</ContentControl>
</Grid>
</RibbonWindow>
Run Code Online (Sandbox Code Playgroud)
有没有办法阻止窗口这样做?