1 / 27

Welcome...

Welcome. Poboljšajte UI/UX vaših Windows (Phone) 8 aplikacija na jednostavan način. Toni Petrina Ekobit d.o.o. MVP for C# @to_pe http://tonicodes.net/blog/. Agenda. MVVM Attached properties – poor man’s behaviors Behaviors Triggers Fun . Windows Phone 8 Windows 8.1. MVVM.

ulla
Download Presentation

Welcome...

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Welcome...

  2. Poboljšajte UI/UX vaših Windows (Phone) 8 aplikacijanajednostavannačin Toni Petrina Ekobit d.o.o. MVP for C# @to_pe http://tonicodes.net/blog/

  3. Agenda MVVM Attached properties – poor man’s behaviors Behaviors Triggers Fun  Windows Phone 8 Windows 8.1

  4. MVVM

  5. Što je MVVM • Model-View-ViewModel • Idealan pattern za aplikacije bazirane na XAML-u • Separacija koda u tri sloja • Lagan Unit Testing • Pogodan za višeplatformski razvoj • Ključno pravilo: nema koda u code-behind

  6. Binding • Sve kontrole se pune preko bindinga • Zamjena za evente su komande (ICommand) • Button.Command je zamjena za Click event • Ali nemaju sve kontrole komande! • Što sa ListBox.SelectionChanged, Manipulation* • Smijemo li samo ovaj put prekršiti pravilo?

  7. Windows Phone

  8. Extensions

  9. Attached properties • Nalijepe se na kontrolu • Znaju kad se nalijepe • Nije zamišljeno za dinamičnost • Nemamo dodatne parametre • Nemamo nikakav state

  10. Attached properties - code publicstaticclassAttachedProperties { publicstaticstringGetMyStatic(UIElementelement)     { returnelement.GetValue(MyStaticProperty) asstring;     } publicstaticvoidSetMyStatic(UIElementelement, stringvalue)     { element.SetValue(MyStaticProperty, value);     } publicstaticDependencyPropertyMyStaticProperty= DependencyProperty.RegisterAttached( "MyStatic", typeof (string), typeof (ListBox), newPropertyMetadata(string.Empty, PropertyChangedCallback)); privatestaticvoidPropertyChangedCallback( DependencyObjectdependencyObject, DependencyPropertyChangedEventArgsdependencyPropertyChangedEventArgs)     {     } }

  11. Attached properties –XAML xmlns:wp8="clr-namespace:WP8" <ListBox wp8:AttachedProperties.MyStatic="hello"> </ListBox>

  12. Demo

  13. Behaviors • Most između viewa i viewmodela • Znamo kad se kontrola aktivira i kad se deaktivira • Dinamično i može imati vlastite propertye • Microsoft.Expression.Interactions • System.Windows.Interactivity

  14. Behavior<T> – kod publicclassListBoxBehavior : Behavior<ListBox> { protectedoverridevoidOnAttached()     { base.OnAttached();     } protectedoverridevoidOnDetaching()     { base.OnDetaching();     } }

  15. Behavior<T> – XAML xmlns:wp8="clr-namespace:WP8„ xmlns:i="clr-namespace:System.Windows.Interactivity; assembly=System.Windows.Interactivity" <ListBox wp8:AttachedProperties.MyStatic="hello"> <i:Interaction.Behaviors> <wp8:ListBoxBehavior /> </i:Interaction.Behaviors> </ListBox>

  16. Demo

  17. Prednosti behaviora • Reusable • Mogu se koristiti u Blendu • Mogu sadržavati dependency propertiese • Imaju neki state

  18. „Ostatak” interakcije • Topom na muhe • Kad želimo samo brzo povezati komandu iz viewmodela na event – trigger • Triggeri se „okinu” kad se nešto dogodi • I oni izvršavaju akciju • Na event – EventTrigger • Na promjenu propertya (INPC) - PropertyChangedTrigger

  19. Važni za spomenuti • DataStateBehavior • NavigateToPageAction • StoryboardCompletedTrigger • DataStateBehavior

  20. Demo

  21. Windows 8.1

  22. Behaviors SDK (8.1)

  23. IBehavior • Sami trebamo implementirati Behavior<T> klasu • Imamo IBehavior i IAction • Fale triggeri, pogotovo oni s ciljem • Možemo samo implementirati traženje kontrole

  24. Demo

  25. Važni za spomenuti • CallMethodAction • ChangePropertyAction • DataTriggerBehavior • EventTriggerBehavior • GoToStateAction • NavigateToPageAction • http://blendbehaviors.net/

  26. Zaključak • Logiku vani iz code-behinda • Iskoristite razne efekte na više projekata • Have fun 

  27. Hvala!

More Related