diff --git a/docs/spec/styles.md b/docs/spec/styles.md index 89d5348397..053d91b1e0 100644 --- a/docs/spec/styles.md +++ b/docs/spec/styles.md @@ -49,6 +49,16 @@ As in CSS, controls can be given *style classes* which can be used in selectors: +Each control can be given 0 or more style classes. This is different to WPF +where only a single style can be applied to a control: in Perspex any number +of separate styles can be applied to a control. If more than one style affects +a particular property, the style closest to the control will take precedence. + +Style classes can also be manipulated in code using the `Classes` collection: + + control.Classes.Add("blue"); + control.Classes.Remove("red"); + ## Pseudoclasses Also as in CSS, controls can have pseudoclasses; these are classes that are diff --git a/docs/tutorial/from-wpf.md b/docs/tutorial/from-wpf.md index 34f1025951..0b4fd82646 100644 --- a/docs/tutorial/from-wpf.md +++ b/docs/tutorial/from-wpf.md @@ -40,6 +40,29 @@ placed in a `DataTemplates` collection on each control (and on `Application`): +`ItemsControl`s don't currently have an `ItemTemplate` property: instead just +place the template for your items into the control's `DataTemplates`, e.g. + + + + + + + + + +Data templates in Perspex can also target interfaces and derived classes (which +cannot be done in WPF) and so the order of `DataTemplate`s can be important: +`DataTemplate`s within the same collection are evaluated in declaration order +so you need to place them from most-specific to least-specific as you would in +code. + +## HierachicalDataTemplate + +WPF's `HierarchicalDataTemplate` is called `TreeDataTemplate` in Perspex (as the +former is difficult to type!). The two are almost entirely equivalent except +that the `ItemTemplate` property is not present in Perspex. + ## UIElement, FrameworkElement and Control WPF's `UIElement` and `FrameworkElement` are non-templated control base classes, @@ -79,12 +102,23 @@ reasons](http://www.codemag.com/article/1501091) for this, but briefly: ## Grid -Perspex has a `Grid` panel just like WPF, however a common use of `Grid` in WPF -is to stack two controls on top of each other. For this purpose in Perspex you -can just use a `Panel` which is more lightweight than `Grid`. +Column and row definitions can be specified in Perspex using strings, avoiding +the clunky syntax in WPF: + + + +A common use of `Grid` in WPF is to stack two controls on top of each other. +For this purpose in Perspex you can just use a `Panel` which is more lightweight +than `Grid`. We don't yet support `SharedSizeScope` in `Grid`. +## ItemsControl + +In WPF, `ItemsControl` and derived classes such as `ListBox` have two separate +items properties: `Items` and `ItemsSource`. Perspex however just has a single +one: `Items`. + ## Tunnelling Events Perspex has tunnelling events (unlike UWP!) but they're not exposed via