Windows UI Notes
2 subscribers
8 photos
Talks about Windows Presentation Foundation, WinUI3 and other dotnet related things.

#Windows #WinUI #WPF #XAML #UI #CSharp #dotnet
Download Telegram
Channel created
Hello, fellow tech enthusiasts! 👋

This channel is dedicated to exploring the world of Windows Presentation Foundation (WPF), a powerful framework for building desktop applications on Windows. Whether you're a seasoned developer or just starting out, we'll dive into the nuts and bolts of WPF together.

In this channel, we'll cover several areas, including
Fundamentals: Understanding the basics of XAML and the power of controls.
Learning curve: Sharing the ups and downs of the learning process.
Community wisdom: Share insights and tips from all levels of experience.
Hands-on: Discuss real-world projects and their issues.
Ecosystem: Explore topics related to the .NET ecosystem.

Let's embark on this learning adventure together and unlock the full potential of WPF! 🚀
Taking on WPF 📖

I’ve just started diving into “Mastering Windows Presentation Foundation” by Sheridan Yuen.

It’s a straightforward guide to WPF and MVVM that’s already proving to be a big help.📝

It might be a bit advanced for beginners, but it’s exactly what I needed to kickstart my learning.

#WPF #MVVM #Book 📚
🔥2❤1
Resource Dictionaries
It's a pretty big topic, but in a nutshell a resource dictionary is a container for reusable resources. Resources can be styles, templates, converters, colors, or any other object.

Instantiating
Each visual tree element (control, panel, window) and application can define its own local resources.
Define resources with a key (similar to a name):
<ResourceDictionary>
<x:String
x:Key="greeting">Hello, world!</x:String>
</ResourceDictionary>


Referencing
When referencing a resource, the search starts locally and continues up the visual tree hierarchy. If not found there, it extends to the root (usually the Application level).
To reference a resource in XAML you can use StaticResource syntax:
<TextBlock Text="{StaticResource greeting}" Foreground="Gray"/>

Here, `greeting` is the key of the resource.

When referenced, the new object is not instantiated; instead, it is retrieved from the existing dictionary.

#WPF #ResourceDictionaries #StaticResource
👏1
Have you thought about chaining async and sync in one call?

Suppose you have a class that implements the Builder pattern. Some of its methods are async and some are sync.

So here is an example of how to do it:
1. Create a wrapper that will hold your actions to be executed.
2. Add a base class for your builders, it holds your commands and calls them at the end of your chain
3. Write your class with the necessary methods. Note that we don't do any work in the methods except the Count() method, we just add an action to the Commands list.
4. Finally, you can chain your methods and round them off with an async method, Count() in the example.
5. Here is the console output.

As a result, in my opinion, you have quite readable code.

#Csharp #Tips
👍2