How to Create Layout Components - EASY WPF (.NET CORE)

preview_player
Показать описание
Learn how to create layout components in WPF in order to reduce XAML duplication. I demonstrate two different ways to create layout components.

The first example uses a styled ContentControl, which is quick and easy to setup. The second example uses a UserControl, which gives us more flexibility and customization with dependency properties and other C#/WPF configuration.

Рекомендации по теме
Комментарии
Автор

An another super useful video. Thank you so much!

labor_e
Автор

Thanks for the tutorials, it helps me revise some WPF stuffs. Unfortunately, I have an issue with Text="{Binding Header, ElementName=root}", I think I'll have to try with a RelativeSource and FindAncestor methods like you suggested. I can't find any typo in the code, but the only difference I can see it that I use a .NET Framework 4.8 (which I use for my target app, because I call COM objects) project instead of .Net Core 3.1. Could it be a reason of my issue?

ludovicwagner
Автор

Sean, I have a question. When I create collection inside user control loaded event, my combobox doesn't display any data. But if I call same method in viewmodel constructor, I get correct data in combo box. I observed that collection has data when I debug in loaded event, but is not displayed onto UI.

Can you please help me or guide me in right direction 😇😊

VinuP
Автор

Hey Sean, not sure if you are still monitoring this, but I am trying to replicate it and having a bit of trouble. In the user control that I am defining as the template, I am trying to import a resource (image) to use. Basically, it is a logo that I want on all forms. When I comment the image reference out, the method works, but as of now, the build breaks on that line when I try and import. Any suggestions?

simonpusateri
Автор

Hi Sean, thanks for all your videos, I find them all really helpful. But let me say there is a drawback with this method. You cannot name another controls inside a user control content.

mcnets
Автор

Hi Sean, can you make a video about creating/customizing a popup dialog(message box)?

benedictpardo
Автор

Thank you, Styles were exactly what I was looking for!

Is there a way to have some events inside the Style? I have tried to make my window header as a Style element like you showed in your example and then reuse it across multiple plugins, but I got an issue when I tried to handle events.

MouseDrag = 'header_drag'

Failed to create a 'MouseDown' from the text 'header_drag'. ---> System.ArgumentException: Cannot bind to the target method because its signature or security transparency is not compatible with that of the delegate type.

erikfrits
Автор

I this enough by just saying <contentpresenter/> you don't need to specify the `templatebinding content`

ivandrofly
Автор

How do you declare Layout Component to inherit the DataContext from that in the ContentPresenter? GetType() shows the same but they have different instances. Thank you.

yummysatay
Автор

Thanks Sean. Just one question before I watch and reimplement this tutorial, components are .net core specific?

VinuP
Автор

How can you do this in a MVVM approach?

mihaimyh
Автор

can we do something like this?
so for example having a grid and use it inside other grids like this ->



and also if a grid has their own grid.definitions to override the default?

FuzzyDPozzy
welcome to shbcf.ru