Coder Social home page Coder Social logo

controlzex / controlzex Goto Github PK

View Code? Open in Web Editor NEW
925.0 48.0 113.0 13.7 MB

Shared Controlz for WPF and ... more

License: MIT License

C# 99.94% PowerShell 0.05% Batchfile 0.01%
wpf xaml control controlzex windowchrome shell windows oss open-source tooltips

controlzex's Introduction

ControlzEx

Shared Controlz for WPF

Supporting .NET Framework (4.5.2, 4.6.2 and greater), .NET Core (3.1) and .NET 5 (on Windows)

ControlzEx

Join the chat at https://gitter.im/ControlzEx/ControlzEx

Build status Release Downloads Issues Nuget License

Twitter Jan Twitter Bastian Twitter James

Let's get started

TextBoxInputMaskBehavior

The TextBoxInputMaskBehavior can be used to show a mask inside a TextBox.

Note: It's only a mask and does not validate your text.

<TextBlock Grid.Row="0"
           Grid.Column="0"
           Margin="4"
           Text="Datetime" />
<TextBox Grid.Row="0"
         Grid.Column="1"
         Margin="4">
    <behaviors:Interaction.Behaviors>
        <controlzEx:TextBoxInputMaskBehavior InputMask="00/00/0000" />
    </behaviors:Interaction.Behaviors>
</TextBox>

<TextBlock Grid.Row="1"
           Grid.Column="0"
           Margin="4"
           Text="Phone Number" />
<TextBox Grid.Row="1"
         Grid.Column="1"
         Margin="4">
    <behaviors:Interaction.Behaviors>
        <controlzEx:TextBoxInputMaskBehavior InputMask="( 999 ) 000 000 - 00"
                                             PromptChar="_" />
    </behaviors:Interaction.Behaviors>
</TextBox>

The original TextBoxInputMaskBehavior was taken from from Blindmeis's Blog.

InputMaskScreenshot

KeyboardNavigationEx

The KeyboardNavigationEx is a helper class for a common focusing problem. The focus of an UI element itself isn't the problem. But if we use the common focusing methods, the control gets the focus, but it doesn't get the focus visual style.

The original KeyboardNavigation class handles the visual style only if the control gets the focus from a keyboard device or if the SystemParameters.KeyboardCues is true.

With KeyboardNavigationEx you can fix this in two simple ways.

In code behind:

public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();
        this.Loaded += (s, e) => { KeyboardNavigationEx.Focus(this.TheElementWhichShouldGetTheFocus); };
    }
}

or in XAML:

<Button controlzex:KeyboardNavigationEx.AlwaysShowFocusVisual="True">Hey, I get the focus visual style on mouse click!</Button>

keyboardfocusex

AutoMove ToolTip

An auto moving ToolTip. More Info.

<Button Margin="5"
        Padding="5"
        Content="Test Button 2"
        ToolTipService.ShowDuration="20000">
    <Button.ToolTip>
        <ToolTip local:ToolTipAssist.AutoMove="True">
            <ToolTip.Template>
                <ControlTemplate>
                    <Grid>
                        <Border Background="Gray"
                                BorderBrush="Black"
                                BorderThickness="1"
                                Opacity="0.9"
                                SnapsToDevicePixels="True" />
                        <TextBlock Margin="5"
                                    Foreground="WhiteSmoke"
                                    FontSize="22"
                                    Text="ToolTipHelper AutoMove sample"
                                    TextOptions.TextFormattingMode="Display"
                                    TextOptions.TextRenderingMode="ClearType" />
                    </Grid>
                </ControlTemplate>
            </ToolTip.Template>
        </ToolTip>
    </Button.ToolTip>
</Button>

automove_tooltip2

automove_tooltip

GlowWindowBehavior

The GlowWindowBehavior adds a Glow around your window.
Starting with Windows 11 the behavior can be used to control the color of the native window border and automatically does so, when Windows 11 is detected.
This can be turned off by setting PreferDWMBorder to false.

WindowChromeBehavior

ControlzEx provides a custom chrome for WPF windows and some other deeper fixes for it.

What it does provide:

  • Draw anywhere inside the window (including the titlebar)
  • Supports every WindowStyle (None, SingleBorderWindow, ThreeDBorderWindow and ToolWindow)
  • Supports jitter free window resizes
  • Allows you to ignore the taskbar when the window is maximized
  • Provides an IsNCActive property
  • Mitigates a bug in Windows that causes newly shown windows to briefly be shown with a pure white background
  • Starting with Windows 11:
    • Allows you to control rounded corners (through CornerPreference)
    • Supports snap menu on window buttons (through attached properties like NonClientControlProperties.HitTestResult and NonClientControlProperties.ClickStrategy)

Most of the fixes and improvements are from MahApps.Metro and Fluent.Ribbon.

Concrete implementation of techniques described here:

Blog entry from Microsoft on custom Window chrome

It's a fork of the original Microsoft WPF Shell Integration Library. Current Microsoft's implementation can be found:

PopupEx

Custom Popup that can be used in validation error templates or something else like in MaterialDesignInXamlToolkit or MahApps.Metro.

PopupEx provides some additional nice features:

  • repositioning if host-window size or location changed
  • repositioning if host-window gets maximized and vice versa
  • it's only topmost if the host-window is activated

2015-10-11_01h03_05

TabControlEx

Custom TabControl that keeps the TabItem content in the VisualTree while unselecting them, so no re-create nightmare is done, after selecting the TabItem again. The visibility behavior can be set by ChildContentVisibility dependency property.

Usage:

<controlz:TabControlEx>
    <TabItem Header="Lorem">
        <TextBlock Text="Lorem ipsum dolor sit amet, consetetur sadipscing"
                   HorizontalAlignment="Center"
                   FontSize="30" />
    </TabItem>
    <TabItem Header="ipsum">
        <TextBox Text="Lorem ipsum dolor sit amet, consetetur sadipscing"
                 HorizontalAlignment="Center"
                 Margin="5" />
    </TabItem>
</controlz:TabControlEx>

PackIconBase

A base class to help drive a common method for creating icon packs in WPF.

To create a new icon pack follow these steps:

Define a key (typically an enum):

public enum PackIconKind
{
    Happy,
    Sad
}

Subclass PackIconBase, adding

  • Default style key
  • A factory providing Path data for each key
public class PackIcon : PackIconBase<PackIconKind>
{
    static PackIcon()
    {
        DefaultStyleKeyProperty.OverrideMetadata(typeof(PackIcon), new FrameworkPropertyMetadata(typeof(PackIcon)));
    }

    public PackIcon() : base(CreateIconData)
    { }

    private static IDictionary<PackIconKind, string> CreateIconData()
    {
        return new Dictionary<PackIconKind, string>
        {
            {PackIconKind.Happy, "M20,12A8,8 0 0,0 12,4A8,8 0 0,0 4,12A8,8 0 0,0 12,20A8,8 0 0,0 20,12M22,12A10,10 0 0,1 12,22A10,10 0 0,1 2,12A10,10 0 0,1 12,2A10,10 0 0,1 22,12M10,9.5C10,10.3 9.3,11 8.5,11C7.7,11 7,10.3 7,9.5C7,8.7 7.7,8 8.5,8C9.3,8 10,8.7 10,9.5M17,9.5C17,10.3 16.3,11 15.5,11C14.7,11 14,10.3 14,9.5C14,8.7 14.7,8 15.5,8C16.3,8 17,8.7 17,9.5M12,17.23C10.25,17.23 8.71,16.5 7.81,15.42L9.23,14C9.68,14.72 10.75,15.23 12,15.23C13.25,15.23 14.32,14.72 14.77,14L16.19,15.42C15.29,16.5 13.75,17.23 12,17.23Z"},
            {PackIconKind.Sad, "M20,12A8,8 0 0,0 12,4A8,8 0 0,0 4,12A8,8 0 0,0 12,20A8,8 0 0,0 20,12M22,12A10,10 0 0,1 12,22A10,10 0 0,1 2,12A10,10 0 0,1 12,2A10,10 0 0,1 22,12M15.5,8C16.3,8 17,8.7 17,9.5C17,10.3 16.3,11 15.5,11C14.7,11 14,10.3 14,9.5C14,8.7 14.7,8 15.5,8M10,9.5C10,10.3 9.3,11 8.5,11C7.7,11 7,10.3 7,9.5C7,8.7 7.7,8 8.5,8C9.3,8 10,8.7 10,9.5M12,14C13.75,14 15.29,14.72 16.19,15.81L14.77,17.23C14.32,16.5 13.25,16 12,16C10.75,16 9.68,16.5 9.23,17.23L7.81,15.81C8.71,14.72 10.25,14 12,14Z"}
        };
    }
}

Provide a default style (typically in your Generic.xaml, e.g:

<Style TargetType="{x:Type local:PackIcon}">
    <Setter Property="Height" Value="16" />
    <Setter Property="Width" Value="16" />
    <Setter Property="HorizontalAlignment" Value="Left" />
    <Setter Property="VerticalAlignment" Value="Top" />
    <Setter Property="IsTabStop" Value="False" />
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type local:PackIcon}">
                <Viewbox>
                    <Canvas Width="24" Height="24">
                        <Path Data="{Binding Data, RelativeSource={RelativeSource TemplatedParent}}"
                              Fill="{TemplateBinding Foreground}" />
                    </Canvas>
                </Viewbox>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

Your users should now have a simple way to use your icon pack in their applications:

<ns:PackIcon Kind="HappyIcon" />

Theming

ControlzEx provides a ThemeManager which helps you to provide Theming to your App.
For more information see this section.

Licence

The MIT License (MIT)

Copyright (c) since 2015 Jan Karger, Bastian Schmidt, James Willock

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

controlzex's People

Contributors

amkuchta avatar batzen avatar butchersboy avatar froggiefrog avatar geertvanhorrik avatar gep13 avatar gitter-badger avatar jizc avatar keboo avatar lakritzator avatar punker76 avatar teadrivendev avatar timunie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

controlzex's Issues

NullReferenceException: ControlzEx.Behaviors.WindowChromeBehavior.HandleBorderAndResizeBorderThicknessDuringMaximize()

Stack Trace:

System.NullReferenceException: Referência de objeto não definida para uma instância de um objeto.
   em ControlzEx.Behaviors.WindowChromeBehavior.HandleBorderAndResizeBorderThicknessDuringMaximize()
   em ControlzEx.Behaviors.WindowChromeBehavior.HandleMaximize()
   em ControlzEx.Behaviors.WindowChromeBehavior.AssociatedObject_SourceInitialized(Object sender, EventArgs e)
   em System.EventHandler.Invoke(Object sender, EventArgs e)
   em System.Windows.Window.OnSourceInitialized(EventArgs e)
   em System.Windows.Window.CreateSourceWindow(Boolean duringShow)
   em System.Windows.Window.ShowHelper(Object booleanBox)
   em WDG.Automation.Studio.Modules.Debugger.Services.DebugBarManager.Show(Boolean alwaysOpened) na Services\DebugBarManager.cs:linha 30
   em WDG.Automation.Studio.Modules.Shell.ViewModels.MainWindowViewModel.WindowDeactivated(Object sender, EventArgs e) na ViewModels\MainWindowViewModel.cs:linha 61
   em System.EventHandler.Invoke(Object sender, EventArgs e)
   em System.Windows.Window.OnDeactivated(EventArgs e)
   em System.Windows.Window.HandleActivate(Boolean windowActivated)
   em System.Windows.Window.WmActivate(IntPtr wParam)
   em System.Windows.Window.WindowFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   em System.Windows.Interop.HwndSource.PublicHooksFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   em MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   em MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   em System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   em System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

[Suggestion] Change PackIconBase.Kind to DependencyProperty

Hi,

I'm currently working with MaterialDesignInXamlToolkit and MahApps.Metro to create a nice looking UI for my app. Both of them use the PackIconBase from this project to provide nice looking icons.

I quite like the idea and would like to propose to change the implementation of the Kind property of PackIconBase to be changed to a DependencyProperty, so i can change the icon during runtime via setters in xaml. I have a workaround to change the parent control via templating, but I'd prefer to be able to just change the Kind property directly.

Is this possible and a good idea?

Need Logo / Icon

This project needs a logo, but, I'm no designer so would be very happy if someone could design an logo/icon for ControlzEx.

Obviously this project is open source so there would be no payment, but if anyone can provide a decent logo which suits this project then I'll link to their website/portfolio for the lifetime of this project.

What's the spec? Well, it's this project: a control suite for XAML/WPF/.NET, specially a custom WindowChorme which fixes a lot of stuff...

Ideally the icon would be provided in .ico and/or .png format as well as the xaml path.

//cc @snalty

Window content context menu opens with system context menu

Opening system menu on the window title leads to the opening context menu from the client area content. See attached sample project.
Steps to reproduce:

  • Start the test app
  • DO NOT MOVE the window!!
  • right mouse button click on the „Header“ area
  • the system menu opens, additional opens the richtextbox context menu

22-05-_2019_16-09-29

SystemMenuBug.zip

OverflowException when converting 64-bit IntPtr to Int32

In WindowChromeWorker, in the following function:

private IntPtr _HandleNCHitTest(WM uMsg, IntPtr wParam, IntPtr lParam, out bool handled)

The input parameter lParam is converted using Utility.GET_X_LPARAM and Utility.GET_Y_LPARAM. This function performs a ToInt32() on the pointer.

When running on 64-bit, the pointer value can be larger than Int32.MaxValue and in that case, the "ToInt32" is throwing an OverflowException.

On my mouse, I have a scroll button which I can tilt. For some reason, when I tilt the scroll button the "lParam" input get's crazy high values, larger than Int32.MaxValue. This triggers an OverflowException and crashes my app.

[BUG] how to build ?

i try to build
but i have problem
i download a zip
i try to open sln with vs2017
but 2 project are not loaded
when i tru to load i have message "MSBuild.Sdk.Extras" not install

how i can install it ?

PackIcon Data property not being set.

While trying to create my own PackIcons I noticed the icon I wanted was not being displayed. It turned out that the data property was not being set on the PackIcon.

While debugging my application the KindPropertyChangedCallback was not being called and so the Data was never being updated.

I created a test application for the bug which you can view here: https://github.com/niceprogramming/PackIconTest

This is just a base project and only includes code from the README

_HandleNCACTIVATE is causing child windows to not be interactive

The change in this commit is causing child windows to not be interactive. Mouse over still works, but no mouse clicks get through (with the exception of dragging the title bar). After reverting that specific change, it works as expected again.

To reproduce

  1. Clone test repo https://github.com/jizc/ControlzEx
  2. Run Showcase
  3. Click OPEN CHILD WINDOW button at the bottom
  4. Try to click any button in the child window

Expected behavior

  • The buttons in the child test window should change the color of the window's background
  • Should be able to close child window by clicking the close button in the top-right corner

Arithmetic Overflow

Heyo,

I just got this stack trace while using my software while using the latest MahApps alpha. My software can no longer start. 😅

Target Site: ControlzEx.Standard.WS SetWindowStyle(IntPtr, ControlzEx.Standard.WS)
Message: Arithmetic operation resulted in an overflow.
Stack Trace: 
   at ControlzEx.Standard.NativeMethods.SetWindowStyle(IntPtr hWnd, WS dwNewLong) in C:\projects\controlzex\src\ControlzEx\Microsoft.Windows.Shell\Standard\NativeMethods.cs:line 3414
   at MahApps.Metro.Controls.GlowWindow.OnSourceInitialized(EventArgs e) in C:\...\MahApps.Metro\MahApps.Metro.Shared\Controls\GlowWindow.xaml.cs:line 200
   at System.Windows.Window.CreateSourceWindow(Boolean duringShow)
   at System.Windows.Window.CreateSourceWindowDuringShow()
   at System.Windows.Window.SafeCreateWindowDuringShow()
   at System.Windows.Window.ShowHelper(Object booleanBox)
   at System.Windows.Window.Show()
   at MahApps.Metro.Behaviours.GlowWindowBehavior.Show() in C:\...MahApps.Metro\MahApps.Metro.Shared\Behaviours\GlowWindowBehavior.cs:line 253
   at MahApps.Metro.Behaviours.GlowWindowBehavior.AssociatedObjectOnLoaded(Object sender, RoutedEventArgs routedEventArgs) in C:\...\MahApps.Metro\MahApps.Metro.Shared\Behaviours\GlowWindowBehavior.cs:line 132
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
   at System.Windows.BroadcastEventHelper.BroadcastEvent(DependencyObject root, RoutedEvent routedEvent)
   at System.Windows.BroadcastEventHelper.BroadcastLoadedEvent(Object root)
   at MS.Internal.LoadedOrUnloadedOperation.DoWork()
   at System.Windows.Media.MediaContext.FireLoadedPendingCallbacks()
   at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
   at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
   at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
   at System.Windows.Media.MediaContext.Resize(ICompositionTarget resizedCompositionTarget)
   at System.Windows.Interop.HwndTarget.OnResize()
   at System.Windows.Interop.HwndTarget.HandleMessage(WindowMessage msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Interop.HwndSource.HwndTargetFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)

Ability to Adjust Badge Control Placement

It would be super awesome to be able to have the ability to adjust the position of the Badged Controls at a granular level; my thought is that the best way to do so would be to implement a BadgeMargin property on PART_BadgeContainer, which users could then use to shift the control up/down/left/right in conjunction with the BadgePlacementMode.

@punker76 @ButchersBoy , thoughts on this?

Showtitlebar can not fill all screen

Before run I set titlebar invisible and all buttons invisible.

public MainWindow()
        {
            InitializeComponent();
            IgnoreTaskbarOnMaximize = false;
            ShowMaxRestoreButton = false;
            ShowMinButton = false;
            ShowTitleBar = false;
            ShowCloseButton = false;
        }

image
Then I set them back, the window can not fill the screen

private void Button_Click(object sender, RoutedEventArgs e)
       {
           ShowMaxRestoreButton = true;
           ShowMinButton = false;
           ShowMinButton = true;
           ShowTitleBar = true;
           ShowCloseButton = true;
       }

image

Replace code for WindowChrome and related classes

The code for WindowChrome and related classes should be replaced with the code from MahApps.Metro.
That way all fixes which were made there in the past already apply to this project and future maintenance gets easier.

Window Border has Wrong Color

The window border (on Windows 10 and probably on other versions) has a wrong color. This is visible on the illustration below. Wrong color (left) and default color (right).
windowborder

Some debugging shows that you use DwmExtendFrameIntoClientArea for the border. For this to work correctly, the area under the border must be painted black (poorly documented in https://msdn.microsoft.com/en-us/library/windows/desktop/bb688195(v=vs.85).aspx). But you use the border brush, which makes the shaders produce strange results. This is especially visible with non-standard border colors, for example #FF2B579A or the FluentRibbon sample. Setting the border color to black produces the default bluish border color taken from the Windows style.

To make things worse, there appears to be a bug in the RDP implementation. Using the above technique with WinForms works correctly. But when the app is written in WPF and the users connects remotely via RDP (Remote Desktop), I guess that the DirectX surface is somehow transferred differently and the DwmExtendFrameIntoClientArea does not work and produces a black border (the effective border color). I've written two simple test apps to verify this and WinForm works but not WPF. Those contain very few lines of almost identical code (let me know if you want them).

To work around the above mentioned issue, I change the border color depending on the session type (local or remote). I also listen for changes and change the border color on the fly, when the session type changes (black for local sessions, bluish for remote sessions). Listen to events from Microsoft.Win32.SystemEvents.SessionSwitch and test for GetSystemMetrics(SM_REMOTESESSION).

This works for us, because our app has a bluish color scheme and there is not much difference between the default Windows border color and our bluish color (users won't notice it). However, if the app has a different color, some other tricks are needed. Some googling hinted DwmSetColorizationParameters, but this is undocumented. Since this is no priority for us, I did not investigate.

Crashes with .NET 4.61: Could not load type 'System.Windows.DpiScale' in PresentationCore

With the latest of Dragablz version (0.0.3.203) I'm seeing failures in a deployed application when users are running pre-4.62 versions of .NET.

This is inside Markdown Monster and I'm seeing a lot of these errors in my analytics logs:

image

This started after installing the latest version of Dragablz - none before the update.

MM is compiled against .NET 4.62 (need the new DPI Scaling features) but we bump down the supported runtime all the way to 4.52 to allow older versions of .NET to work (more info on why here). This has been working great without issues up to now.

So my question is - any idea what's changed that might be causing this issue and is there anything I can do about it?

Release .NET 4.6.2 version

We should provide a .NET 4.6.2 version.
In that version things like per monitor dpi can work properly as Microsoft only added the required .NET methods VisualTreeHelper.GetDpi in .NET 4.6.2.

Exception has been thrown by the target of an invocation. ControlzEx 4.0

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ComponentModel.Win32Exception: 0x80070578
at ControlzEx.Standard.HRESULT.ThrowIfFailed(String message)
at ControlzEx.Standard.HRESULT.ThrowLastError()
at ControlzEx.Standard.NativeMethods.GetWindowLongPtr(IntPtr hwnd, GWL nIndex)
at ControlzEx.Behaviors.WindowChromeBehavior._UpdateMinimizeSystemMenu(Boolean isVisible)
at ControlzEx.Behaviors.WindowChromeBehavior.OnEnableMinimizePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
at System.Windows.Freezable.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
at System.Windows.DependencyObject.InvalidateProperty(DependencyProperty dp, Boolean preserveCurrentValue)
at System.Windows.Data.BindingExpressionBase.Invalidate(Boolean isASubPropertyChange)
at System.Windows.Data.BindingExpression.TransferValue(Object newValue, Boolean isASubPropertyChange)
at System.Windows.Data.BindingExpression.ScheduleTransfer(Boolean isASubPropertyChange)
at MS.Internal.Data.ClrBindingWorker.NewValueAvailable(Boolean dependencySourcesChanged, Boolean initialValue, Boolean isASubPropertyChange)
at MS.Internal.Data.PropertyPathWorker.UpdateSourceValueState(Int32 k, ICollectionView collectionView, Object newValue, Boolean isASubPropertyChange)
at MS.Internal.Data.PropertyPathWorker.OnDependencyPropertyChanged(DependencyObject d, DependencyProperty dp, Boolean isASubPropertyChange)
at MS.Internal.Data.ClrBindingWorker.OnSourceInvalidation(DependencyObject d, DependencyProperty dp, Boolean isASubPropertyChange)
at System.Windows.Data.BindingExpression.HandlePropertyInvalidation(DependencyObject d, DependencyPropertyChangedEventArgs args)
at System.Windows.Data.BindingExpressionBase.OnPropertyInvalidation(DependencyObject d, DependencyPropertyChangedEventArgs args)
at System.Windows.Data.BindingExpression.OnPropertyInvalidation(DependencyObject d, DependencyPropertyChangedEventArgs args)
at System.Windows.DependentList.InvalidateDependents(DependencyObject source, DependencyPropertyChangedEventArgs sourceArgs)
at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
at System.Windows.DependencyObject.InvalidateProperty(DependencyProperty dp, Boolean preserveCurrentValue)
at System.Windows.Data.BindingExpressionBase.Invalidate(Boolean isASubPropertyChange)
at System.Windows.Data.BindingExpression.TransferValue(Object newValue, Boolean isASubPropertyChange)
at System.Windows.Data.BindingExpression.ScheduleTransfer(Boolean isASubPropertyChange)
at MS.Internal.Data.ClrBindingWorker.NewValueAvailable(Boolean dependencySourcesChanged, Boolean initialValue, Boolean isASubPropertyChange)
at MS.Internal.Data.PropertyPathWorker.UpdateSourceValueState(Int32 k, ICollectionView collectionView, Object newValue, Boolean isASubPropertyChange)
at MS.Internal.Data.ClrBindingWorker.OnSourcePropertyChanged(Object o, String propName)
at MS.Internal.Data.PropertyPathWorker.OnPropertyChanged(Object sender, PropertyChangedEventArgs e)
at System.Windows.WeakEventManager.ListenerList1.DeliverEvent(Object sender, EventArgs e, Type managerType) at System.ComponentModel.PropertyChangedEventManager.OnPropertyChanged(Object sender, PropertyChangedEventArgs args) at System.ComponentModel.PropertyChangedEventHandler.Invoke(Object sender, PropertyChangedEventArgs e) at GalaSoft.MvvmLight.ObservableObject.RaisePropertyChanged(String propertyName) at GalaSoft.MvvmLight.ObservableObject.RaisePropertyChanged[T](Expression1 propertyExpression)
at RL.Wpf.MES.Utilities.Env.set_IsAdmin(Boolean value)
at RL.Wpf.MES.ViewModel.LoginViewModel.LoginViewModel.LoginSwitch()
at RL.Wpf.MES.ViewModel.BasicViewModel.CollapseMenuViewModel.CancelChange(ButtonModel model)
at RL.Wpf.MES.ViewModel.BasicViewModel.CollapseMenuViewModel.set_SelectButtonModel(ButtonModel value)
at RL.Wpf.MES.ViewModel.BasicViewModel.CollapseMenuViewModel.GotoPageByName(BillMenu name)
at RL.Wpf.MES.ViewModel.BasicViewModel.CollapseMenuViewModel.ExecuteQuickGoPage(BillMenu page)
at RL.Wpf.MES.ViewModel.BasicViewModel.CollapseMenuViewModel.<get_QuickGoPageCommand>b__47_0(BillMenu page)
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at GalaSoft.MvvmLight.Helpers.WeakAction1.Execute(T parameter) at GalaSoft.MvvmLight.Command.RelayCommand1.Execute(Object parameter)
at MS.Internal.Commands.CommandHelpers.CriticalExecuteCommandSource(ICommandSource commandSource, Boolean userInitiated)
at System.Windows.Controls.Primitives.ButtonBase.OnClick()
at System.Windows.Controls.Button.OnClick()
at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
at System.Windows.UIElement.OnMouseLeftButtonUpThunk(Object sender, MouseButtonEventArgs e)
at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
at System.Windows.UIElement.OnMouseUpThunk(Object sender, MouseButtonEventArgs e)
at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
at System.Windows.Input.InputManager.ProcessStagingArea()
at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)

Xaml behaviors for .net core wpf

when use it will show the warning below:

Warning NU1701 Package 'Microsoft.Xaml.Behaviors.Wpf 1.0.1' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v3.0'. This package may not be fully compatible with your project.

How to fix it?

Win32Exception on closing window

We have a WPF app with Fluent.Ribbon that uses this library.

We run this app on a remote machine using Remote Desktop connection.
If the app's main window (with ribbon) is maximized, closing this window causes an exception.
Here is the stack trace:

System.ComponentModel.Win32Exception (0x80004005): The parameter is incorrect
   at Standard.NativeMethods.SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, Int32 x, Int32 y, Int32 cx, Int32 cy, SWP uFlags)
   at ControlzEx.Microsoft.Windows.Shell.WindowChromeWorker._HandleMoveForRealSize(WM uMsg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at ControlzEx.Microsoft.Windows.Shell.WindowChromeWorker._WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at System.Windows.Interop.HwndSource.PublicHooksFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.HwndSubclass.DefWndProcWrapper(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)

A EntryPointNotFoundException exception occurred on the XP OS

I have a app that uses MetroWindow, which will crash when running on XP OS. I found the reason is that MahApps.Metro calls the NativeMethods.TryGetPhysicalCursorPos method, but this method (GetPhysicalCursorPos) is only supported in Vista or newer OS.

I think we can fix this with the following code:

(in ControlzEx\Microsoft.Windows.Shell\Standard\NativeMethods.cs Line 3211)

        public static bool TryGetPhysicalCursorPos(out POINT pt)
        {
            bool returnValue = false;
            if (Utility.IsOSVistaOrNewer) // Doesn't call it if the OS isn't Vista or newer
                returnValue = _GetPhysicalCursorPos(out pt);
            else
                pt = new POINT();

            // Sometimes Win32 will fail this call, such as if you are
            // not running in the interactive desktop. For example,
            // a secure screen saver may be running.
            if (!returnValue)
            {
                System.Diagnostics.Debug.WriteLine("GetPhysicalCursorPos failed!");
                pt.X = 0;
                pt.Y = 0;
            }
            return returnValue;
        }

and

(in ControlzEx\Microsoft.Windows.Shell\Standard\NativeMethods.cs Line 3198)

        public static POINT GetPhysicalCursorPos()
        {
            POINT pt = new POINT();

            if (Utility.IsOSVistaOrNewer && !_GetPhysicalCursorPos(out pt)) // Doesn't call it if the OS isn't Vista or newer
            {
                HRESULT.ThrowLastError();
            }

            return pt;
        }

If you allow, I will be happy to submit a pull request for it.

Maximising a RibbonWindow with MaxWidth or MaxHeight causes an extra border above the title bar

Copied from fluentribbon/Fluent.Ribbon#456

If a RibbonWindow has either MaxWidth or MaxHeight set (to a value less than the screen size), when maximising the window there is an extra border along the top edge. Looking closely it appears that there's extra window chrome being shown around the edge of the ribbon window, but it's more obvious at the top edge because there are tiny minimise/maximise/close buttons in the corner separate from the ribbon's buttons.

It's colour is independent from the ribbon background so stands out on a dark theme.

I can reproduce it in the showcase application by adding MaxWidth="1000" to TestWindow.xaml.

Screenshot (the red border I added in paint to highlight where it is :))
border

Fully transparent window

I write plug-ins CAD and BIM in which I used Mahapps.Metro. But in view of the fact that conflicts often occur with other plugins that also use Mahapps.Metro, I decided to make my library based on Mahapps.Metro.
I have introduced the ControlzEx library into my library:
image

Everything turned out, except for one problem - if I turn on transparency (AllowsTransparency="True" Opacity=".8") in the test project, then the window appears completely transparent. However, it appears and when I could grab it with the mouse and maximize it to the full screen, it appeared! And after it was curled back to normal, it continued to work normally.

In my window, I removed the GlowWindowBehavior and left only BorderlessWindowBehavior and WindowsSettingBehaviour.
image

Tell me where to look for the problem? It seems to me that the problem is somewhere in BorderlessWindowBehavior

Crash in DeactivateTaskbarFix

I have daily users getting crash in the following method (I am not using directly ControlzEx but Mahapps)

  • ControlzEx : 3.0.2.4
  • Mahapps : 1.6.5.1
  • VS 2017
  • Framework 4.6.2
  • Windows 6.3.17134.0 (for this one but happens on multiple version)

Anything I can do to at least trap it and avoid a crash?

System.ComponentModel.Win32Exception: El identificador de la ventana no es válido
   en ControlzEx.Behaviors.WindowChromeBehavior.DeactivateTaskbarFix(IntPtr trayWndHandle)
   en ControlzEx.Behaviors.WindowChromeBehavior.HandleMaximize()
   en ControlzEx.Behaviors.WindowChromeBehavior.AssociatedObject_StateChanged(Object sender, EventArgs e)
   en System.EventHandler.Invoke(Object sender, EventArgs e)
   en System.Windows.Window.OnStateChanged(EventArgs e)
   en System.Windows.Window.WmSizeChanged(IntPtr wParam)
   en System.Windows.Window.WindowFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   en System.Windows.Interop.HwndSource.PublicHooksFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   en MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   en MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   en System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   en System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

Borderless Window Style goes wrong

Imported from MahApps/MahApps.Metro#3516

Describe the bug
Original window style can be seen when switch window in Win7.

To Reproduce
Steps to reproduce the behavior:

  1. Open demo application. Notice the top-left corner and top-right corner of window.
  2. Open VS window.
  3. Switch between VS window and main window. Notice the style of VS window.
  4. See error
  5. Maximize and restore VS window. Switch between windows. Style won't change anymore.

Expected behavior
CornerRadius should be 0. And style of window should not change.

Screenshots
[Expected]
Expected
[Actual]
Actual
[Screen record]
record

Environment(please complete the following information):

  • MahApps.Metro version [latest code in develop branch]
  • OS: [Win7 SP1]
  • Visual Studio [dotenet core 3.0 preview 5]
  • .NET Framework [4.6]

Additional context
This only happen in some real machines. But it can be easy reproduced on virtual machine. And once you set Performance Options -> Visual Effects -> Adjust for best performance. This problem will no longer exist.

Note
@wunianqing This is related to the new/changed implementation of the borderless behavior in ControlzEx v4.0 alpha.

/cc @batzen I can reproduce this in a Win7 test VM, but didn't know how to solve this. (Another effect is while changing focus from Window to another Window is that the win 7 aero theme is shown for one second. I don't know if I want to fix this... 🙈 )

2019-06-03_12h50_42

mahapps_controlzex_win7

UnauthorizedAccessException from ToolTipAssist.AutoMove

We use ToolTipAssist.AutoMove in a few places in our application. We now got an error report with an UnauthorizedAccessException and the following stack trace:

System.UnauthorizedAccessException: E_ACCESSDENIED
   at Standard.HRESULT.ThrowIfFailed(String message)
   at ControlzEx.Helper.MonitorHelper.GetMonitorInfoFromPoint()
   at ControlzEx.ToolTipAssist.MoveToolTip(IInputElement target, ToolTip toolTip)
   at ControlzEx.ToolTipAssist.ToolTip_Opened(Object sender, RoutedEventArgs e)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.Controls.Primitives.Popup.CreateWindow(Boolean asyncCall)
   at System.Windows.Controls.Primitives.Popup.OnIsOpenChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
   at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
   at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
   at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
   at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
   at System.Windows.DependencyObject.InvalidateProperty(DependencyProperty dp, Boolean preserveCurrentValue)
   at System.Windows.Data.BindingExpressionBase.Invalidate(Boolean isASubPropertyChange)
   at System.Windows.Data.BindingExpression.TransferValue(Object newValue, Boolean isASubPropertyChange)
   at MS.Internal.Data.PropertyPathWorker.UpdateSourceValueState(Int32 k, ICollectionView collectionView, Object newValue, Boolean isASubPropertyChange)
   at MS.Internal.Data.PropertyPathWorker.OnDependencyPropertyChanged(DependencyObject d, DependencyProperty dp, Boolean isASubPropertyChange)
   at System.Windows.Data.BindingExpression.HandlePropertyInvalidation(DependencyObject d, DependencyPropertyChangedEventArgs args)
   at System.Windows.Data.BindingExpressionBase.OnPropertyInvalidation(DependencyObject d, DependencyPropertyChangedEventArgs args)
   at System.Windows.Data.BindingExpression.OnPropertyInvalidation(DependencyObject d, DependencyPropertyChangedEventArgs args)
   at System.Windows.DependentList.InvalidateDependents(DependencyObject source, DependencyPropertyChangedEventArgs sourceArgs)
   at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
   at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
   at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
   at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
   at System.Windows.Controls.PopupControlService.RaiseToolTipOpeningEvent()
   at System.Windows.Threading.DispatcherTimer.FireTick(Object unused)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)

This is an isolated incident (we've been using it for a few months), and we don't know how to reproduce it, so this is probably an odd edge case (maybe the underlying Win32 call failed because something else was happening in that same instant) and nothing that needs an urgent fix.

It seems reasonable to just catch and ignore an UnauthorizedAccessException in that instance and not move the tooltip for that one call to MoveToolTip().

VS 2017 Cannot Load projects

I downloaded the source code and try to open it in VS 2017, however, projects cannot be loaded. and there is noing in the Output pane.

what I can do?

thanks!
Tiger

For information, MetroWindow, MaterialDesign source codes downloaded from GitHub works fine on my computer.
Fluent.Ribbon has the same issue too.

controlzex

InvalidOperationException while closing

I can't reproduce this on my machine, but it gets logged. Doesn't matter much as it's during closing but it should be possible to check first if window is already closed.

I'm using latest ControlzEx pre version.

System.InvalidOperationException: Cannot set Visibility or call Show, ShowDialog, or WindowInteropHelper.EnsureHandle after a Window has closed.
at System.Windows.Window.VerifyCanShow() at offset 23
at System.Windows.Window.CoerceVisibility(System.Windows.DependencyObject d, System.Object value) at offset 23
at System.Windows.DependencyObject.ProcessCoerceValue(System.Windows.DependencyProperty dp, System.Windows.PropertyMetadata metadata, System.Windows.EntryIndex& entryIndex, System.Int32& targetIndex, System.Windows.EffectiveValueEntry& newEntry, System.Windows.EffectiveValueEntry& oldEntry, System.Object& oldValue, System.Object baseValue, System.Object controlValue, System.Windows.CoerceValueCallback coerceValueCallback, System.Boolean coerceWithDeferredReference, System.Boolean coerceWithCurrentValue, System.Boolean skipBaseValueChecks) at offset 99
at System.Windows.DependencyObject.UpdateEffectiveValue(System.Windows.EntryIndex entryIndex, System.Windows.DependencyProperty dp, System.Windows.PropertyMetadata metadata, System.Windows.EffectiveValueEntry oldEntry, System.Windows.EffectiveValueEntry& newEntry, System.Boolean coerceWithDeferredReference, System.Boolean coerceWithCurrentValue, System.Windows.OperationType operationType) at offset 649
at System.Windows.DependencyObject.SetValueCommon(System.Windows.DependencyProperty dp, System.Object value, System.Windows.PropertyMetadata metadata, System.Boolean coerceWithDeferredReference, System.Boolean coerceWithCurrentValue, System.Windows.OperationType operationType, System.Boolean isInternal) at offset 682
at System.Windows.DependencyObject.SetValue(System.Windows.DependencyProperty dp, System.Object value) at offset 27
at ControlzEx.Controls.GlowWindow.SetVisibilityIfPossible(System.Windows.Visibility newVisibility) at offset 28
at ControlzEx.Controls.GlowWindow.Update() at offset 132
at ControlzEx.Controls.GlowWindow.<.ctor>b__15_23(System.Object sender, System.EventArgs e) at offset 6
at System.EventHandler.Invoke(System.Object sender, System.EventArgs e)
at System.Windows.Window.OnActivated(System.EventArgs e) at offset 31
at System.Windows.Window.WmActivate(System.IntPtr wParam) at offset 41
at System.Windows.Window.WindowFilterMessage(System.IntPtr hwnd, System.Int32 msg, System.IntPtr wParam, System.IntPtr lParam, System.Boolean& handled) at offset 198
at System.Windows.Interop.HwndSource.PublicHooksFilterMessage(System.IntPtr hwnd, System.Int32 msg, System.IntPtr wParam, System.IntPtr lParam, System.Boolean& handled) at offset 46
at MS.Win32.HwndWrapper.WndProc(System.IntPtr hwnd, System.Int32 msg, System.IntPtr wParam, System.IntPtr lParam, System.Boolean& handled) at offset 48
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object o) at offset 54
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate callback, System.Object args, System.Int32 numArgs) at offset 119
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object source, System.Delegate callback, System.Object args, System.Int32 numArgs, System.Delegate catchHandler) at offset 2

Strong-Naming again...

The author of the (in)famous "Still strong naming your assemblies?" blog article has now done an about-face and now advocates strong-naming your assemblies again in an update to that same blog post:

Though the information and concerns in this blog post are still very true, I’ve actually had a change of heart and I’m now advocating to Start Strong-Naming your Assemblies!!

Start Strong-Naming your Assemblies!

Microsoft's corefx team also now strong-names and while they say not every assembly needs it, it's still useful: https://github.com/dotnet/corefx/blob/master/Documentation/project-docs/strong-name-signing.md

Maximizing a window with a WindowChromeBehavior.IgnoreTaskbarOnMaximize set to false makes it unusable

Hello,

I have some kind of issue with my custom window and WindowChromeBehavior.
When not maximized, it runs fine and resizes fine, however, when maximized, a previously fixed problem appears again:
image
The window gets stuck to the top left corner and is passing clicks through other windows.
This only happens when IgnoreTaskbarOnMaximize is set to false.
This does not happen with a normal window, only with my custom one.
Here is a cut version of the template:

<ControlTemplate TargetType="{x:Type controls:ThemedWindow}">
    <Grid>
        <AdornerDecorator x:Name="Adorner">
            <Grid Background="{TemplateBinding Background}">
                <Grid.RowDefinitions>
                    <RowDefinition Height="20"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>
                <Grid x:Name="PART_MoveArea" Background="Transparent">
                    <Viewbox VerticalAlignment="Center" HorizontalAlignment="Left" Margin="10 1">
                        <TextBlock Text="{TemplateBinding Title}" />
                    </Viewbox>
                </Grid>
                <StackPanel Grid.Row="0" Grid.Column="1" Orientation="Horizontal">
                    <!-- Title bar buttons -->
                </StackPanel>
                <ContentPresenter Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="2" Margin="2"/>
            </Grid>
        </AdornerDecorator>
        <ResizeGrip x:Name="WindowResizeGrip"/>
        <!-- + usual props -->
        <Border BorderThickness="{TemplateBinding BorderThickness}"
                                BorderBrush="{TemplateBinding BorderBrush}" 
                                Background="{x:Null}"
                                HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
    </Grid>
    <!-- Triggers -->
</ControlTemplate>

And here is the WindowChromeBehavior:

new WindowChromeBehavior
{
    IgnoreTaskbarOnMaximize = false,
    ResizeBorderThickness = new Thickness(5),
    KeepBorderOnMaximize = true,                  
};

NativeMethods.SetActiveWindow fails with error E_INVALIDARG

Using Fluent Ribbon 7.0.0-alpha.456 with ControlzEx 4.0.0.189. We got this extremely rare error. I guess the only possible reason is that the HWND got destroyed or something, and ControlzEx code has a race condition where it calls the method with an invalid handle.

Message:
Unhandled Exception:E_INVALIDARG

Exception:
at ControlzEx.Standard.HRESULT.ThrowIfFailed(String message) at ControlzEx.Standard.NativeMethods.SetActiveWindow(IntPtr hwnd) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)

Maximize problem when using glass frame

I'm experiencing an issue when maximizing windows (both in my application and in the showcase). When selecting NoneWindowStyle everything works as expected. However when using NoneWindowStyleWithGlassFrame, every other time I maximize the window, the top 8 pixels of the window are cut off.

image

More or less helpful info:

  • I'm using Windows 10 - 1803.17134.48 - x64
  • I have a 2 monitor setup, the dpi scale on both is 1 (the problem persists if I change the dpi, but the amount of pixels cut of increases with the scale i.e. 12 pixels cut off when using 1.25 dpi scale)
  • I'm seeing the same effect when maximizing on both monitors
  • The problem goes away if I enable IgnoreTaskbarOnMaximize
  • If I maximize the window by dragging it to the top of the monitor, it always works as expected
  • It happens consistently in all 3 showcases (NET40, NET45, NET462)
  • The problem persists in the WindowChromeNext branch
  • lParam in _HandleNCCalcSize is providing a different Top and Bottom when the problem occurs and setting it to rcWork is not correcting it (Top is -8 when it's working, 8 when the problem occurs)
  • If I step through the code when maximizing, the problem does not occur

I've been trying to solve this for hours and I'm at the end of my rope, so I hope you can help 😄

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.