Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Selecting objects on a WPF canvas?
Message
De
26/02/2009 13:48:39
 
 
À
26/02/2009 03:19:11
Information générale
Forum:
ASP.NET
Catégorie:
Windows Presentation Foundation (WPF)
Divers
Thread ID:
01383557
Message ID:
01384357
Vues:
30
>If you want the style to apply to all HolePattern objects (and only HolePattern objects or sub-classes) you can achieve this just in XAML. Make 'HolePattern' the TargetType and omit the x:Key attribute. The style will then be applied to all HolePattern objects regardless of how or when they are added to the Canvas.
>HTH,
>Viv

Well, I've used blanketing styles in other places in my XAML to dynamically build the UI based on the active HolePattern. So, that's cool to also realize how it could be automatically assigned to every Ellipse in the window in the same manner.

However, let me make sure I understand something, becuase what you sugessted above does not work...

In the app, I have 2 custom classes that make up the main working architecture of the thing... HolePattern, and Hole. So, HolePattern is a collection of Holes, and each of these are custom classes, and neither is a Shape base class, but the Hole class does have a Shape object as a member field, and that Ellipse shape is what I work from for populating the canvas.

So, you said target 'HolePattern', (but I think you meant 'Hole'), but even then, I do not think it will work, as those are not visual Shape classes.

HolePattern (custom class), has a collection member that contains a list of Hole class objects
+--- Hole (custom class) a single hole
+--- Ellipse (a Shape object on the Hole that can be added to a Canvas) --------- Must apply style to this

Am I right? I type in Hole and HolePattern in the XAML, and even the pre-compiler complained about not being able to resolve it. I think the TargetType has to remain Ellipse. Maybe you though Hole was a Shape class, and in that case I bet it would would work.


By the way, I have posted the source code for this up on CodePlex, so you can download the source zip file from there, and see the current screenshot. When you get time to download and run it, please let me know what think. Be sure to read the Project Description so you'll see the plug I gave you for helping me out.

http://www.codeplex.com/WPFHolePatterns
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform