简体   繁体   中英

Windows 8 native custom control

I want to make a custom control with the Windows 8 API in C# so that it will run on an RT app distributed through the store.

I looked through what I can add to a project and found Templated Control and User Control . Both allow me to organize other controls and some logic into a new control for reusability.

But this isn't what I want. I want to be able to custom paint and create controls. I would be shocked if they removed this but am honestly uncertain if I can. I'm basically looking for what class to inherit from and what method / event to override to let me draw the control myself.

I found a way to use the Templated Control option that I wasn't aware of before. Essentially my custom control has a canvas that I 'paint' with objects (lines, images, etc.) by adding them as children and manipulating them in events.

This tutorial helped me figure out what I was doing.

I've seen other people say they created a rectangle and painted it with a special Brush, either a ImageBrush (where they drew an image in the background) or a DrawingBrush.

Hopefully one of these two approaches can help anyone looking for the same thing I was.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM