VincentH-Net / CSharpForMarkup

Concise, declarative C# UI markup for .NET browser / native UI frameworks
MIT License
748 stars 43 forks source link

What are some examples of CustomControls? #41

Closed lukewire129 closed 3 months ago

lukewire129 commented 3 months ago

I have a situation where I need to create a CustomControl, and I've been stumped for days because I don't see any examples using DepencyProperty other than ControlTemplate in the current examples.

I was wondering if there are any relevant examples

VincentH-Net commented 3 months ago

@lukewire129 the generated code for existing controls are your best examples here. Pick an existing control that resembles your custom control (or just a simple control), e.g. Image, and then open the generated source for that control (either with F12 or in this repo under Generated). You will see the source for that control within it's own namespace braces, e.g. namespace CSharpMarkup.WinUI // Image. You can also search for // Image with entire words option.

It will show you how to use DependencyProperty. Feel free to report back here if you need more help!