locked
App.xaml Resources Style ListViewItemPresenter - UniversalApp

    Question

  • I have some Listview witch i change the selected color to blue then when i tried to build the Phone i got ListViewItemPresenter was not found. Is there a way to use

    #if WINDOWS_APP
    #endif
    #if WINDOWS_PHONE_APP
    #endif

    or something similar in xaml?. Cause i have alote of listview in my app and i dont want to copy the style in all the pages.

     
    Monday, June 09, 2014 5:49 PM

Answers

  • Where are you putting the dictionary?

    A good pattern for this is to have separate app.xaml files for each platform and each can have its own platform specific styles. In many cases you'll want to have the entire Xaml page in the platform specific project so that it can be designed differently for both form factors.

    --Rob

    • Marked as answer by St4mos Monday, June 09, 2014 8:45 PM
    Monday, June 09, 2014 8:13 PM
    Owner
  • I copy - paste App.xml to each platform project and then deleted it from the shared. For now it works fine.

    Will i have a problem?

    • Marked as answer by St4mos Monday, June 09, 2014 8:45 PM
    Monday, June 09, 2014 8:32 PM

All replies

  • No, there is no conditional compiling for xaml. You'll need to put platform specific xaml in the platform specific projects.
    Monday, June 09, 2014 6:25 PM
    Owner
  • I have 7 ListView in 7 different pages is there a good way to bypass copying the style to all pages? 

    I ve tried to use Dictionary but for some reason it doesnt find the style.

    Monday, June 09, 2014 7:30 PM
  • Using ResourceDictionary is the best way to manage the styles.

    - Ram
    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    Monday, June 09, 2014 8:06 PM
  • Where are you putting the dictionary?

    A good pattern for this is to have separate app.xaml files for each platform and each can have its own platform specific styles. In many cases you'll want to have the entire Xaml page in the platform specific project so that it can be designed differently for both form factors.

    --Rob

    • Marked as answer by St4mos Monday, June 09, 2014 8:45 PM
    Monday, June 09, 2014 8:13 PM
    Owner
  • I copy - paste App.xml to each platform project and then deleted it from the shared. For now it works fine.

    Will i have a problem?

    • Marked as answer by St4mos Monday, June 09, 2014 8:45 PM
    Monday, June 09, 2014 8:32 PM
  • Not from that. From an individual build target's perspective there is no difference if the file is in the platform specific project or in Shared. Both are treated as a single unit. It doesn't matter if a given file is in the platform specific or the shared project.

    The important part for Shared is that it's part of both the Windows Store and the Windows Phone projects and so the same file can easily be included in both.

    --Rob

    Monday, June 09, 2014 8:35 PM
    Owner
  • Ok Thanks Rob!

    Ram I agree, I usually use just the App.xaml for my styles but maybe I ll start using Dictionary.

    Monday, June 09, 2014 8:44 PM