Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Xamarin.Forms 使いこなし術

Xamarin.Forms 使いこなし術

JXUG#18で発表した内容

yo ohtagawa

October 28, 2016
Tweet

More Decks by yo ohtagawa

Other Decks in Programming

Transcript

  1. ϩʔΧϥΠζ΍Δͱ͖ͷ஫ҙ఺ • PCL΍iOSͰ͸ ‘zh-Hans’, ’zh-Hant’͕࢖͑·͕͢ɺ Xamarin.AndroidͰ͸ ‘zh-CN’, ‘zh-TW’͔͠࢖͑ͳ͍ • iOSͰ͸ResxΛ࢖༻͢Δ৔߹͸ඞཁͳ͍Ͱ͕͢ɺ

    info.plistͰCFBundleLocalizationsʹݴޠίʔυΛઃఆ ͠ͳ͍ͱίϯτϩʔϧͷσϑΥϧτςΩετ͕มΘΒͳ ͍
 ex: Picker΍KeyboardͷDone ΍ NavigationͷBack
  2. Xamarin Studio͋Δ͋Δ • XSͰ͸σϑΥϧτ໊ͷ ”Resources” ͸มߋਪ঑
 Xamarin.Forms.Resources Ϋϥε͕ଘࡏ͢ΔͷͰඃΓ ·͢ •

    VS͸σβΠφʔͰ௥ՃͰ͖Δ͕
 XS͸XmlͰ΍Δ͔͠ͳ͍…ͭΒ͍… <data name=“Hoge_Text" xml:space="preserve"> <value>Hoge</value> <comment>͜Ε͸΄͛Λදࣔ͢ΔςΩετͰ͢</comment> </data>
  3. ࢲతݟղ ͦͷ̍ • Ͳ͜·Ͱڞ༗͢Δʁ • Xamarin.FormsʢPCLʣͰݺͼग़͢ςΩετ͸Ϛετ • ઃఆͰݺͼग़͢ςΩετ͸ωΠςΟϒ • ios:

    ΞϓϦ໊
 ϓϥΠόγʔΞΫηεͷUsageDescription ← new! • android: ΞϓϦ໊ • ը૾͸ωΠςΟϒͷํ๏ • ݴޠͱαΠζͷؔ܎͕ີ • ೉͍͜͠ͱߟ͑ΔΑΓ΋ී௨ͷํ๏Ͱ
 σόΠεʹ༏͍͠ΞϓϦ͕͓͢͢Ί
  4. ࢲతݟղ ͦͷ2 • ϩʔΧϥΠζͱ͍͏ࢹ఺Ͱߟ͑Δ • ݴޠ΍ը૾Λม͑Δ΋ͷ͸αϙʔ τ͞Ε͍ͯΔ • ͕ʂਂ͘ϩʔΧϥΠζͱߟ͑Δͱ ͦ΋ͦ΋FormsΛ࢖͏͜ͱΛߟ͑

    ௚͠·͠ΐ͏ • ΞϥϏΞޠͳͲͷςΩετ͕ӈ͔Βࠨ ΁ͷݴޠͷ৔߹͸Layout Λࠨӈٯʹ ͢Δඞཁ͕͋Γ·͢ • αϙʔτΛߟ͑ΔͳΒ͹ΦϨΦϨ࣮૷ ͢ΔΑΓ΋ωΠςΟϒ͔Βαϙʔτ͞ Ε͍ͯΔػೳΛ࢖͍·͠ΐ͏(^^)
  5. FormsͷػೳΛ࢖͍෼͚ • Triggers • Behaviors • Effects • Custom Renderers

    • Dependency Service • Messaging Center • Properties Dictionary
  6. FormsͷػೳΛ࢖͍෼͚ • Triggers PCLͷΈͰগ͠Πϕϯτ͔ΒViewΛม͍͑ͨɻ΋͔ͯ͠͠ ValueConverter? • Behaviors PCLͷΈͰ৽͍͠৚݅Λ૿΍͢ɻ˓˓ͯ͠Έͨɻ • Effects

    Platformຖ࣮૷Ͱ͖Δɻ࠶ར༻ੑ͕ߴ͍ ← ͕͜͜ॏཁ • Custom Renderers ͳΜͰ΋ग़དྷΔ༏౳ੜɻListViewͰ͸ Custom RendererҎ֎͋Γ͑ͳ͍www • Dependency Service FormsͷఱఢɻϋʔυͷAPIΛݺΜͩΓɺPlatformͷҧ͍ΛΫογϣϯͯ͘͠ΕΔ • Messaging Center ϫʔΫΞϥ΢ϯυɻͲ͔͜ΒͰ΋ϝοηʔδΛૹΓɺड৴ଆʹॲཧͤ͞Δ͜ͱ͕ग़དྷΔ • Properties Dictionary ϫʔΫΞϥ΢ϯυɻͲ͔͜ΒͰ΋Forms͕ఏڙͯ͘͠ΕΔσΟΫγϣφϦʔʹอଘग़དྷΔ
  7. Embedded Native Controls • PlatformಠࣗͷίϯτϩʔϧΛFormsͰݺͼग़ͤΔ • v2.3.0 ʹshared projectͷΈՄೳ •

    v2.3.3 ͔Β͸ɺxamlͷΈPCLͰ΋Մೳ • ౰ͨΓલͰ͕͢…
 ݱࡏ͸ɺ x:Name ࢖༻ෆՄ
 ίʔυϏϋΠϯυ͕ग़དྷͳ͍ͷͰBindingʹͯߦ͍· ͠ΐ͏ɻ