Code Monkey home page Code Monkey logo

modernwpfcommunitytoolkit's Introduction

ModernWpfCommunityToolkit

The ModernWpf Community Toolkit is a collection of helper functions and custom controls for the ModernWpf library.

This project incorporates components from the Windows Community Toolkit. The Windows Community Toolkit's license and 3rd party notices could be found here and here respectively.

ModernWpf Community Toolkit & the Windows Community Toolkit

First of all, we must thank the contributors of the WCT for their awesome work on the toolkit.

The ModernWpf Community Toolkit (MCT) is a port of the well-known & popular Windows Community Toolkit to WPF/ModernWpf.

The Windows Community Toolkit (WCT) [being a part of the .NET Foundation and actively developed by Microsoft and the community] is a collection of helper functions, custom controls and app services which simplifies and helps the development of UWP apps for Windows.

It has some parts which depend on some UWP only APIs (which can't be used from Win32 apps). And some parts are dependent on the UWP XAML (aka WinUI). Thus, rendering the WCT unusable from some application (such as pure WPF apps).

To resolve this barrier, ModernWpf Community Toolkit was made.

ModernWpf Community Toolkit is also a collection of helper functions and custom controls but for building WPF (Win32) apps.

This toolkit depends on another well-known & popular library called ModernWpf which brings WinUI controls & styles to WPF applications. Whereas, this toolkit brings some WCT controls & helpers to WPF.

There may be some differences (in APIs or availability of some features) between MCT and WCT due to certain difference between WPF (.NET) & UWP (WinRT) APIs.

Most of the source code are ported from the WCT (some differences or variations can be found).

This toolkit contains ported custom controls and some features that are not restricted UWP only from WCT.

Parts of the WCT which target .NET Standard (as you can use them from any .NET library/application) are not ported. However, some WinUI (UWP XAML) specific features are ported.

This toolkit also contains some additional controls and helpers that are WPF or ModernWpf specific.

So, ModernWpf โ‰‹ WinUI and MCT โ‰‹ WCT.

NuGet Packages

NuGet Package Latest Versions
ModernWpf.Toolkit latest stable version
latest prerelease version
ModernWpf.Toolkit.UI latest stable version
latest prerelease version
ModernWpf.Toolkit.UI.Controls latest stable version
latest prerelease version
ModernWpf.Toolkit.UI.Controls.Markdown latest stable version
latest prerelease version

modernwpfcommunitytoolkit's People

Contributors

shankarbus 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

Watchers

 avatar  avatar  avatar  avatar  avatar

modernwpfcommunitytoolkit's Issues

MarkDownTextBlock System.IO.FileNotFoundException exception on .Net Core 3.1

I'm getting this exception on a MarkDownTextBlock on .Net Core 3.1 and I suspect the cause would be because I am using .Net core. I do have ModernWpfUi installed and this is how my project looks like

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <UseWPF>true</UseWPF>
    <StartupObject>[...]</StartupObject>
    <ApplicationManifest>app.manifest</ApplicationManifest>
    <Version>1.5.0</Version>
    <Nullable>enable</Nullable>
    <Copyright>[...]</Copyright>
    <Description>[...]</Description>
    <LangVersion>latest</LangVersion>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Humanizer.Core" Version="2.8.26" />
    <PackageReference Include="InputSimulator" Version="1.0.4" />
    <PackageReference Include="Melanchall.DryWetMidi" Version="5.2.0" />
    <PackageReference Include="ModernWpf.Toolkit.UI.Controls.Markdown" Version="0.1.0" />
    <PackageReference Include="ModernWpfUI" Version="0.9.4" />
    <PackageReference Include="PropertyChanged.Fody" Version="3.3.3" />
    <PackageReference Include="Stylet" Version="1.3.6" />
  </ItemGroup>

</Project>
System.IO.FileNotFoundException
  HResult=0x80070002
  Message=Could not load file or assembly 'ModernWpf, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
  Source=ModernWpf.Toolkit.UI.Controls.Markdown
  StackTrace:
   at ModernWpf.Toolkit.UI.Controls.MarkdownTextBlock.OnLoaded(Object sender, RoutedEventArgs e)
   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.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.DispatcherOperation.InvokeImpl()
   at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
   at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(Object obj)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Windows.Threading.DispatcherOperation.Invoke()
   at System.Windows.Threading.Dispatcher.ProcessQueue()
   at System.Windows.Threading.Dispatcher.WndProcHook(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)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.Run()
   at System.Windows.Application.RunDispatcher(Object ignore)
   at System.Windows.Application.RunInternal(Window window)
   at System.Windows.Application.Run()

New Property to LinkClickedEventArgs.cs

Can you add a Property to LinkedClickedEventArgs.cs which store the Clicked Text?

using ModernWpf.Toolkit.UI.Controls;

namespace Test 
{
    public class TestWindow : Window
    {

        private void MarkdownTextBlock_OnLinkClicked(object sender, LinkClickedEventArgs e)
        {
            e.Link // Link behind the clicked Text (Already exists)
            e.ClickedText // New Property which store the clicked Text
        }
    }
}

FancyZones editor window does not adapt 225% resize mode setting.

Issue Description:

FancyZones editor window does not adapt 225% resize mode setting.

Test environment:

OS: Windows 10 Build 21354.1

App version: 0.35.0

App name: Power Toys

Prerequisites:

  1. Go to settings > Display settings > Set the resolution to 1280*768.
  2. Set the slider value to maximum i.e., 225% (Settings -> Ease of access -> text scaling) and apply.

Repro steps:

  1. Launch 'PowerToys' application.
  2. Application will get open with default list item 'General' selected.
  3. Navigate to 'FancyZones' at the left side of the pane and activate it.
  4. Now navigate to 'Launch layout editor' button and activate it.
  5. FancyZones editor window will get open.
  6. Observe the issue

Actual results:

FancyZones editor window does not adapt 225% resize mode setting.

Expected results:

FancyZones editor window should adapt 225% resize mode setting.

Attachments:

MAS1.4.4_Edit.zone.editor.window.not.adapting.resize.setting.mp4

Properly attribute Windows Community Toolkit License

Hi!

Really great to see someone back-porting some Windows Community Toolkit code to WPF!

However, I noticed some of the license notices have been stripped from the code copied over (or maybe it's not clear which ones are unique to this project to call out your own license). You still need to preserve the headers for files from the WCT and preserve the copyright within the license:

Copyright (c) .NET Foundation and Contributors
All rights reserved.

Either calling it out in your license file at the top with your name or using a third-party notice file with a copy of our license.

Thanks!

Error message doesn't get identified for the edit fields of edit layout dialog by entering value other than its defined range.

Description:
If Screen reader users are not aware that an error has occurred, they will not be able to determine what is wrong before encountering the error indicator, thinking that the page simply is not functional.

Test Environment:
OS: Windows 11 Build 22000.978
App version: v0.62.1
App name: Power Toys

AT (include version number):
Narrator

Repro Steps:

  1. Launch 'Power Toys' application.
  2. Turn on the Narrator.
  3. Application will get open with default list item 'General' selected.
  4. Navigate to 'Fancy Zones' at the left side of the pane and activate it.
  5. Now navigate to 'Launch layout editor button and activate it.
  6. Fancy Zones editor window will get open.
  7. Navigate to 'Edit layout' button of any layout (say Grid) under Templates and activate it.
  8. Edit layout dialog gets open.
  9. Navigate to the 'Space around zones' edit field and enter the value greater than 1000 say 1500 and press 'Tab key.
  10. Observe the issue.

Actual Result:
Error message doesn't get identified for the edit fields of edit layout dialog by entering value other than its defined range.
Entering value greater than 1000 say '1500' and pressing tab key, value automatically gets change to 1000.
Also, narrator does not announce the minimum and the maximum value of the edit field when focus navigates there.

Expected Result:
Error message should get identified for the edit fields of edit layout dialog by entering value other than its defined range.
Entering value greater than 1000 say '1500' error message should get displayed on the screen such as "Value greater than 1000 not allowed".
Also, narrator should announce the minimum and the maximum value of the edit field when focus navigates there.

Additional Notes:
Same happens with 'Number of zones'. It automatically gets change to 128, whenever we try to enter value more than 128.

Attachment:
https://user-images.githubusercontent.com/93735775/194355981-1358b5fd-3dd2-4b45-b866-7dd9007800bc.mp4

MarkdownTextBlock in VirtualizingStackPanel: "System.ArgumentException: An item with the same key has already been added"

When using MarkDownTextBlock in a DataTemplate of a ListBox and turning on virtualization on that ListBox, eventually MarkdownTextBlock keeps throws the exception "System.ArgumentException: An item with the same key has already been added":

StackTrace is:

   at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
   at ModernWpf.Toolkit.UI.Extensions.DependencyObjectExtensions.RegisterPropertyChangedCallback(DependencyObject dependencyObject, DependencyProperty dependencyProperty, DependencyPropertyChangedCallback callback)
   at ModernWpf.Toolkit.UI.Controls.MarkdownTextBlock.OnLoaded(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.BroadcastEventHelper.BroadcastEvent(DependencyObject root, RoutedEvent routedEvent)
   at System.Windows.BroadcastEventHelper.BroadcastLoadedEvent(Object root)
   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.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
   at ModernWpf.Toolkit.UI.Extensions.DependencyObjectExtensions.RegisterPropertyChangedCallback(DependencyObject dependencyObject, DependencyProperty dependencyProperty, DependencyPropertyChangedCallback callback)
   at ModernWpf.Toolkit.UI.Controls.MarkdownTextBlock.OnLoaded(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.BroadcastEventHelper.BroadcastEvent(DependencyObject root, RoutedEvent routedEvent)
   at System.Windows.BroadcastEventHelper.BroadcastLoadedEvent(Object root)
   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)

Reason for this is that the control registers property change callbacks via DependencyObjectExtensions.RegisterPropertyChangedCallback inside a

Dictionary<long, (DependencyPropertyDescriptor Descriptor, EventHandler Handler)> descriptors

where the key is always descriptors.Count + 1.

When using virtualization MarkDownTextBlocks are dynamically loaded and unloaded while scrolling. Unloading a MarkDownTextBlock calls DependencyObjectExtensions.UnregisterPropertyChangedCallback which removes certain keys from that dictionary.
When calling then DependencyObjectExtensions.RegisterPropertyChangedCallback again, descriptors.Count + 1 might return a key that is already used in the dictionary.


Solution:
A better algorithm for creating a unique key is needed. Suggestion: Guid.New()

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.