In this article I've tried to cover most of all the possible ways to develop different UI for different device families while making apps for Windows 10 UWP. There are couple of ways and we'll elaborate each of those possibilities here.
Using <VisualStateManager> in XAML
This method is more useful when the UI differences between a Windows phone and the desktop (other bigger devices) are not major. Because if the UI of the phone and desktop are entirely different then the code in the XAML file will be more complex and will be hard to maintain for future changes.
Let's take a simple example to understand this. In our project we have a page named MainPage. And in that we took a TextBlock to display the device name.
Here in VisualStateManager we're using AdaptiveTrigger for the app's minimum windows width and through that we're judging if the app is running on phone or desktop.
Take a look at the code of our MainPage.xaml file.
Here in VisualStateManager we're using AdaptiveTrigger for the app's minimum windows width and through that we're judging if the app is running on phone or desktop.
Take a look at the code of our MainPage.xaml file.
- <Grid x:Name="RootGrid" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
- <VisualStateManager.VisualStateGroups>
- <VisualStateGroup>
- <VisualState x:Name="visualStateMobile">
- <VisualState.StateTriggers>
- <AdaptiveTrigger MinWindowWidth="0" />
- </VisualState.StateTriggers>
- <VisualState.Setters>
- <Setter Target="tb.Text" Value="Mobile App" />
- </VisualState.Setters>
- </VisualState>
- <VisualState x:Name="visualStateDesktop">
- <VisualState.StateTriggers>
- <AdaptiveTrigger MinWindowWidth="700" />
- </VisualState.StateTriggers>
- <VisualState.Setters>
- <Setter Target="tb.Text" Value="Desktop App" />
- </VisualState.Setters>
- </VisualState>
- </VisualStateGroup>
- </VisualStateManager.VisualStateGroups>
- <TextBlock x:Name="tb" Text="Desktop App" FontSize="36" HorizontalAlignment="Center" VerticalAlignment="Center" />
- </Grid>
VisualStateManager must always be put on the root grid of any specific page. Here's the output of running this page in desktop and phone.


Using DeviceFamily-Type Folder for each DeviceFamily
To makea completely different UI for phone and desktop, you can use different XAML views for different DeviceFamily.
For that first of all create a folder in your project and name it as "DeviceFamily-type" here type is the DeviceFamily type you're making the design for i.e. Mobile, Desktop, IoT, Team etc.

For that first of all create a folder in your project and name it as "DeviceFamily-type" here type is the DeviceFamily type you're making the design for i.e. Mobile, Desktop, IoT, Team etc.

To understand this way of creating UI we're going to build a sample in which the mobile UI will be majorly different then Desktop UI.
In UWP if any app is providing "Options," or say "Menu," then the place of that menu should be according to the device on which the app is running.
For example if the app is running on Windows phone then the menu should be in the bottom app bar. And if the app is running on a bigger device like a desktop or tablet then the menu should be in the SplitView Pane (Hamburger Menu). We'll build a sample for that.
- Add a page named "MyPage.xaml" in your project which represents the default Page.
- And then add one "XAML View" with the same name but this time add it to the folder we've created "DeviceFamily-Mobile". Remember here in the DeviceFamily-Mobile folder we're adding a "XAML View" instead of "Page".
- So what happens here when the App is running on the Mobile Devices, It will show the XAML view UI from the "DeviceFamily-Mobile" folder and it'll share the Code behind of MyPage.xaml.cs Page we've added in the Project.

Code of MyPage.xaml View -> for Mobile view,
- <Page>
- x:Class="SampleApp.MyPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:SampleApp" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d">
- <Page.BottomAppBar>
- <CommandBar>
- <AppBarButton x:Name="appbarBtnHome" Icon="Home" Label="Home" Click="appbarBtnHome_Click" />
- <AppBarButton x:Name="appbarBtnSettings" Label="Settings" Icon="Setting" Click="appbarBtnSettings_Click" />
- <CommandBar.SecondaryCommands>
- <AppBarButton x:Name="appbarBtnAbout" Label="About" Icon="Import" />
- <AppBarButton x:Name="appbarBtnFeedback" Label="Feedback" Icon="Mail" />
- </CommandBar.SecondaryCommands>
- </CommandBar>
- </Page.BottomAppBar>
- <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
- <TextBlock Text="Mobile App" FontSize="26" HorizontalAlignment="Center" VerticalAlignment="Center" />
- </Grid>
- </Page>






Asfend YarPosted Feb 27, 2016, 1:56 AM
good
Asfend YarPosted Feb 27, 2016, 1:56 AM
great effort
Asfend YarPosted Feb 13, 2016, 12:09 PM
Nice share
Santhakumar MunuswamyPosted Feb 13, 2016, 2:44 AM
Thanks for nice share
Sibeesh VenuPosted Feb 12, 2016, 12:37 AM
Nice Share
Mohammed IbrahimPosted Feb 11, 2016, 1:16 PM
nice