├── .gitattributes ├── .gitignore ├── README.md ├── images ├── WPF.png └── weatherapp.png └── src ├── WeatherApp.sln └── WeatherApp ├── WeatherApp.WPF ├── App.config ├── App.xaml ├── App.xaml.cs ├── Images │ ├── cloud.png │ ├── clouds-background.jpg │ ├── moon.png │ ├── rain-background.jpg │ ├── rain.png │ ├── reload.png │ ├── sun-background.jpg │ └── sun.png ├── MainWindow.xaml ├── MainWindow.xaml.cs ├── OpenTK.dll.config ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings ├── WeatherApp.WPF.csproj └── packages.config └── WeatherApp ├── App.xaml ├── App.xaml.cs ├── AppSettings.cs ├── Controls └── HorizontalList │ └── HorizontalList.cs ├── Converters ├── BackgroundConverter.cs ├── IconConverter.cs └── InverseBoolConverter.cs ├── Models └── Weather.cs ├── Services └── WeatherService.cs ├── ViewModels └── WeatherViewModel.cs ├── Views ├── CustomNavigationPage.xaml ├── CustomNavigationPage.xaml.cs ├── Templates │ ├── WeatherItemTemplate.xaml │ └── WeatherItemTemplate.xaml.cs ├── WeatherView.xaml └── WeatherView.xaml.cs └── WeatherApp.csproj /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | bld/ 21 | [Bb]in/ 22 | [Oo]bj/ 23 | [Ll]og/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | # Uncomment if you have tasks that create the project's static files in wwwroot 28 | #wwwroot/ 29 | 30 | # MSTest test Results 31 | [Tt]est[Rr]esult*/ 32 | [Bb]uild[Ll]og.* 33 | 34 | # NUNIT 35 | *.VisualState.xml 36 | TestResult.xml 37 | 38 | # Build Results of an ATL Project 39 | [Dd]ebugPS/ 40 | [Rr]eleasePS/ 41 | dlldata.c 42 | 43 | # DNX 44 | project.lock.json 45 | artifacts/ 46 | 47 | *_i.c 48 | *_p.c 49 | *_i.h 50 | *.ilk 51 | *.meta 52 | *.obj 53 | *.pch 54 | *.pdb 55 | *.pgc 56 | *.pgd 57 | *.rsp 58 | *.sbr 59 | *.tlb 60 | *.tli 61 | *.tlh 62 | *.tmp 63 | *.tmp_proj 64 | *.log 65 | *.vspscc 66 | *.vssscc 67 | .builds 68 | *.pidb 69 | *.svclog 70 | *.scc 71 | 72 | # Chutzpah Test files 73 | _Chutzpah* 74 | 75 | # Visual C++ cache files 76 | ipch/ 77 | *.aps 78 | *.ncb 79 | *.opendb 80 | *.opensdf 81 | *.sdf 82 | *.cachefile 83 | *.VC.db 84 | *.VC.VC.opendb 85 | 86 | # Visual Studio profiler 87 | *.psess 88 | *.vsp 89 | *.vspx 90 | *.sap 91 | 92 | # TFS 2012 Local Workspace 93 | $tf/ 94 | 95 | # Guidance Automation Toolkit 96 | *.gpState 97 | 98 | # ReSharper is a .NET coding add-in 99 | _ReSharper*/ 100 | *.[Rr]e[Ss]harper 101 | *.DotSettings.user 102 | 103 | # JustCode is a .NET coding add-in 104 | .JustCode 105 | 106 | # TeamCity is a build add-in 107 | _TeamCity* 108 | 109 | # DotCover is a Code Coverage Tool 110 | *.dotCover 111 | 112 | # NCrunch 113 | _NCrunch_* 114 | .*crunch*.local.xml 115 | nCrunchTemp_* 116 | 117 | # MightyMoose 118 | *.mm.* 119 | AutoTest.Net/ 120 | 121 | # Web workbench (sass) 122 | .sass-cache/ 123 | 124 | # Installshield output folder 125 | [Ee]xpress/ 126 | 127 | # DocProject is a documentation generator add-in 128 | DocProject/buildhelp/ 129 | DocProject/Help/*.HxT 130 | DocProject/Help/*.HxC 131 | DocProject/Help/*.hhc 132 | DocProject/Help/*.hhk 133 | DocProject/Help/*.hhp 134 | DocProject/Help/Html2 135 | DocProject/Help/html 136 | 137 | # Click-Once directory 138 | publish/ 139 | 140 | # Publish Web Output 141 | *.[Pp]ublish.xml 142 | *.azurePubxml 143 | # TODO: Comment the next line if you want to checkin your web deploy settings 144 | # but database connection strings (with potential passwords) will be unencrypted 145 | *.pubxml 146 | *.publishproj 147 | 148 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 149 | # checkin your Azure Web App publish settings, but sensitive information contained 150 | # in these scripts will be unencrypted 151 | PublishScripts/ 152 | 153 | # NuGet Packages 154 | *.nupkg 155 | # The packages folder can be ignored because of Package Restore 156 | **/packages/* 157 | # except build/, which is used as an MSBuild target. 158 | !**/packages/build/ 159 | # Uncomment if necessary however generally it will be regenerated when needed 160 | #!**/packages/repositories.config 161 | # NuGet v3's project.json files produces more ignoreable files 162 | *.nuget.props 163 | *.nuget.targets 164 | 165 | # Microsoft Azure Build Output 166 | csx/ 167 | *.build.csdef 168 | 169 | # Microsoft Azure Emulator 170 | ecf/ 171 | rcf/ 172 | 173 | # Windows Store app package directories and files 174 | AppPackages/ 175 | BundleArtifacts/ 176 | Package.StoreAssociation.xml 177 | _pkginfo.txt 178 | 179 | # Visual Studio cache files 180 | # files ending in .cache can be ignored 181 | *.[Cc]ache 182 | # but keep track of directories ending in .cache 183 | !*.[Cc]ache/ 184 | 185 | # Others 186 | ClientBin/ 187 | ~$* 188 | *~ 189 | *.dbmdl 190 | *.dbproj.schemaview 191 | *.pfx 192 | *.publishsettings 193 | node_modules/ 194 | orleans.codegen.cs 195 | 196 | # Since there are multiple workflows, uncomment next line to ignore bower_components 197 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 198 | #bower_components/ 199 | 200 | # RIA/Silverlight projects 201 | Generated_Code/ 202 | 203 | # Backup & report files from converting an old project file 204 | # to a newer Visual Studio version. Backup files are not needed, 205 | # because we have git ;-) 206 | _UpgradeReport_Files/ 207 | Backup*/ 208 | UpgradeLog*.XML 209 | UpgradeLog*.htm 210 | 211 | # SQL Server files 212 | *.mdf 213 | *.ldf 214 | 215 | # Business Intelligence projects 216 | *.rdl.data 217 | *.bim.layout 218 | *.bim_*.settings 219 | 220 | # Microsoft Fakes 221 | FakesAssemblies/ 222 | 223 | # GhostDoc plugin setting file 224 | *.GhostDoc.xml 225 | 226 | # Node.js Tools for Visual Studio 227 | .ntvs_analysis.dat 228 | 229 | # Visual Studio 6 build log 230 | *.plg 231 | 232 | # Visual Studio 6 workspace options file 233 | *.opt 234 | 235 | # Visual Studio LightSwitch build output 236 | **/*.HTMLClient/GeneratedArtifacts 237 | **/*.DesktopClient/GeneratedArtifacts 238 | **/*.DesktopClient/ModelManifest.xml 239 | **/*.Server/GeneratedArtifacts 240 | **/*.Server/ModelManifest.xml 241 | _Pvt_Extensions 242 | 243 | # Paket dependency manager 244 | .paket/paket.exe 245 | paket-files/ 246 | 247 | # FAKE - F# Make 248 | .fake/ 249 | 250 | # JetBrains Rider 251 | .idea/ 252 | *.sln.iml 253 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Weather 2 | 3 | **Weather** is a Xamarin.Forms **WPF backend** application that makes use [OpenWeatherMap.org API](https://openweathermap.org/api), to demonstrate the possibilities of the new backend making use of a great variety of functionality. 4 | 5 | WeatherApp 6 | 7 | Do you want to see the [progress](https://github.com/mohachouch/forms-wpf-progress) of the Xamarin.Forms WPF backend? 8 | 9 |

10 | 11 |

12 | 13 | ## Xamarin.Forms App 14 | 15 | [Xamarin.Forms](https://www.xamarin.com/forms) allows you to build native UIs for iOS, Android, **Windows**, macOS and Linux from a single, shared codebase. You can dive into mobile development with Xamarin.Forms by following our [free self-guided learning](https://university.xamarin.com/classes/track/self-guided) from Xamarin University. This project exercises the following patterns and features: 16 | 17 | * Xamarin.Forms 18 | * [XAML UI](https://developer.xamarin.com/guides/xamarin-forms/xaml/xaml-basics/) 19 | * Converters 20 | * Custom Controls 21 | * [Data Binding](https://developer.xamarin.com/guides/xamarin-forms/xaml/xaml-basics/data_binding_basics/) 22 | * [MVVM](https://developer.xamarin.com/guides/xamarin-forms/xaml/xaml-basics/data_bindings_to_mvvm/) 23 | * [Styles](https://developer.xamarin.com/guides/xamarin-forms/user-interface/styles/) 24 | 25 | ## Requirements 26 | 27 | * [Visual Studio __2015__](https://www.visualstudio.com/en-us/products/vs-2015-product-editions.aspx) Update 3 (14.0 or higher) to compile C# 6 language features (or Visual Studio MacOS) 28 | * Xamarin add-ons for Visual Studio 3.2.1.64 or higher (available via the Visual Studio installer) 29 | * __Visual Studio Community Edition is fully supported!__ 30 | 31 | ## Setup 32 | 33 | **Download** or clone the repository. This is a solution with two projects. 34 | 35 | **Rebuild** the solution to get all neccesary **NuGet** packages. 36 | 37 | Access to **AppSettings.cs** file available in the .NET Standard library to introduce your city. 38 | 39 | Enjoy! 40 | 41 | ## Licenses 42 | 43 | This project is based on [MyWeather.Forms](https://github.com/jamesmontemagno/MyWeather.Forms) by James Montemagno. 44 | 45 | ## Clean and Rebuild 46 | 47 | If you see build issues when pulling updates from the repo, try cleaning and rebuilding the solution. 48 | 49 | ## Copyright and license 50 | 51 | Code released under the [MIT license](https://opensource.org/licenses/MIT). 52 | -------------------------------------------------------------------------------- /images/WPF.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsuarezruiz/xamarin-forms-wpf-weather-sample/254f2f935a26ac9bb00bd587d49c03145762ac5b/images/WPF.png -------------------------------------------------------------------------------- /images/weatherapp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsuarezruiz/xamarin-forms-wpf-weather-sample/254f2f935a26ac9bb00bd587d49c03145762ac5b/images/weatherapp.png -------------------------------------------------------------------------------- /src/WeatherApp.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.26730.3 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WeatherApp", "WeatherApp\WeatherApp\WeatherApp.csproj", "{2381A53A-9CB7-48A0-967B-FB8919AF8FC7}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WeatherApp.WPF", "WeatherApp\WeatherApp.WPF\WeatherApp.WPF.csproj", "{BF8A998F-5014-4043-BAF0-056B665A29A5}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Ad-Hoc|Any CPU = Ad-Hoc|Any CPU 13 | Ad-Hoc|ARM = Ad-Hoc|ARM 14 | Ad-Hoc|iPhone = Ad-Hoc|iPhone 15 | Ad-Hoc|iPhoneSimulator = Ad-Hoc|iPhoneSimulator 16 | Ad-Hoc|x64 = Ad-Hoc|x64 17 | Ad-Hoc|x86 = Ad-Hoc|x86 18 | AppStore|Any CPU = AppStore|Any CPU 19 | AppStore|ARM = AppStore|ARM 20 | AppStore|iPhone = AppStore|iPhone 21 | AppStore|iPhoneSimulator = AppStore|iPhoneSimulator 22 | AppStore|x64 = AppStore|x64 23 | AppStore|x86 = AppStore|x86 24 | Debug|Any CPU = Debug|Any CPU 25 | Debug|ARM = Debug|ARM 26 | Debug|iPhone = Debug|iPhone 27 | Debug|iPhoneSimulator = Debug|iPhoneSimulator 28 | Debug|x64 = Debug|x64 29 | Debug|x86 = Debug|x86 30 | Release|Any CPU = Release|Any CPU 31 | Release|ARM = Release|ARM 32 | Release|iPhone = Release|iPhone 33 | Release|iPhoneSimulator = Release|iPhoneSimulator 34 | Release|x64 = Release|x64 35 | Release|x86 = Release|x86 36 | EndGlobalSection 37 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 38 | {2381A53A-9CB7-48A0-967B-FB8919AF8FC7}.Ad-Hoc|Any CPU.ActiveCfg = Release|Any CPU 39 | {2381A53A-9CB7-48A0-967B-FB8919AF8FC7}.Ad-Hoc|Any CPU.Build.0 = Release|Any CPU 40 | {2381A53A-9CB7-48A0-967B-FB8919AF8FC7}.Ad-Hoc|ARM.ActiveCfg = Release|Any CPU 41 | {2381A53A-9CB7-48A0-967B-FB8919AF8FC7}.Ad-Hoc|ARM.Build.0 = Release|Any CPU 42 | {2381A53A-9CB7-48A0-967B-FB8919AF8FC7}.Ad-Hoc|iPhone.ActiveCfg = Release|Any CPU 43 | {2381A53A-9CB7-48A0-967B-FB8919AF8FC7}.Ad-Hoc|iPhone.Build.0 = Release|Any CPU 44 | {2381A53A-9CB7-48A0-967B-FB8919AF8FC7}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Release|Any CPU 45 | {2381A53A-9CB7-48A0-967B-FB8919AF8FC7}.Ad-Hoc|iPhoneSimulator.Build.0 = Release|Any CPU 46 | {2381A53A-9CB7-48A0-967B-FB8919AF8FC7}.Ad-Hoc|x64.ActiveCfg = Release|Any CPU 47 | {2381A53A-9CB7-48A0-967B-FB8919AF8FC7}.Ad-Hoc|x64.Build.0 = Release|Any CPU 48 | {2381A53A-9CB7-48A0-967B-FB8919AF8FC7}.Ad-Hoc|x86.ActiveCfg = Release|Any CPU 49 | {2381A53A-9CB7-48A0-967B-FB8919AF8FC7}.Ad-Hoc|x86.Build.0 = Release|Any CPU 50 | {2381A53A-9CB7-48A0-967B-FB8919AF8FC7}.AppStore|Any CPU.ActiveCfg = Release|Any CPU 51 | {2381A53A-9CB7-48A0-967B-FB8919AF8FC7}.AppStore|Any CPU.Build.0 = Release|Any CPU 52 | {2381A53A-9CB7-48A0-967B-FB8919AF8FC7}.AppStore|ARM.ActiveCfg = Release|Any CPU 53 | {2381A53A-9CB7-48A0-967B-FB8919AF8FC7}.AppStore|ARM.Build.0 = Release|Any CPU 54 | {2381A53A-9CB7-48A0-967B-FB8919AF8FC7}.AppStore|iPhone.ActiveCfg = Release|Any CPU 55 | {2381A53A-9CB7-48A0-967B-FB8919AF8FC7}.AppStore|iPhone.Build.0 = Release|Any CPU 56 | {2381A53A-9CB7-48A0-967B-FB8919AF8FC7}.AppStore|iPhoneSimulator.ActiveCfg = Release|Any CPU 57 | {2381A53A-9CB7-48A0-967B-FB8919AF8FC7}.AppStore|iPhoneSimulator.Build.0 = Release|Any CPU 58 | {2381A53A-9CB7-48A0-967B-FB8919AF8FC7}.AppStore|x64.ActiveCfg = Release|Any CPU 59 | {2381A53A-9CB7-48A0-967B-FB8919AF8FC7}.AppStore|x64.Build.0 = Release|Any CPU 60 | {2381A53A-9CB7-48A0-967B-FB8919AF8FC7}.AppStore|x86.ActiveCfg = Release|Any CPU 61 | {2381A53A-9CB7-48A0-967B-FB8919AF8FC7}.AppStore|x86.Build.0 = Release|Any CPU 62 | {2381A53A-9CB7-48A0-967B-FB8919AF8FC7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 63 | {2381A53A-9CB7-48A0-967B-FB8919AF8FC7}.Debug|Any CPU.Build.0 = Debug|Any CPU 64 | {2381A53A-9CB7-48A0-967B-FB8919AF8FC7}.Debug|ARM.ActiveCfg = Debug|Any CPU 65 | {2381A53A-9CB7-48A0-967B-FB8919AF8FC7}.Debug|ARM.Build.0 = Debug|Any CPU 66 | {2381A53A-9CB7-48A0-967B-FB8919AF8FC7}.Debug|iPhone.ActiveCfg = Debug|Any CPU 67 | {2381A53A-9CB7-48A0-967B-FB8919AF8FC7}.Debug|iPhone.Build.0 = Debug|Any CPU 68 | {2381A53A-9CB7-48A0-967B-FB8919AF8FC7}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU 69 | {2381A53A-9CB7-48A0-967B-FB8919AF8FC7}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU 70 | {2381A53A-9CB7-48A0-967B-FB8919AF8FC7}.Debug|x64.ActiveCfg = Debug|Any CPU 71 | {2381A53A-9CB7-48A0-967B-FB8919AF8FC7}.Debug|x64.Build.0 = Debug|Any CPU 72 | {2381A53A-9CB7-48A0-967B-FB8919AF8FC7}.Debug|x86.ActiveCfg = Debug|Any CPU 73 | {2381A53A-9CB7-48A0-967B-FB8919AF8FC7}.Debug|x86.Build.0 = Debug|Any CPU 74 | {2381A53A-9CB7-48A0-967B-FB8919AF8FC7}.Release|Any CPU.ActiveCfg = Release|Any CPU 75 | {2381A53A-9CB7-48A0-967B-FB8919AF8FC7}.Release|Any CPU.Build.0 = Release|Any CPU 76 | {2381A53A-9CB7-48A0-967B-FB8919AF8FC7}.Release|ARM.ActiveCfg = Release|Any CPU 77 | {2381A53A-9CB7-48A0-967B-FB8919AF8FC7}.Release|ARM.Build.0 = Release|Any CPU 78 | {2381A53A-9CB7-48A0-967B-FB8919AF8FC7}.Release|iPhone.ActiveCfg = Release|Any CPU 79 | {2381A53A-9CB7-48A0-967B-FB8919AF8FC7}.Release|iPhone.Build.0 = Release|Any CPU 80 | {2381A53A-9CB7-48A0-967B-FB8919AF8FC7}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU 81 | {2381A53A-9CB7-48A0-967B-FB8919AF8FC7}.Release|iPhoneSimulator.Build.0 = Release|Any CPU 82 | {2381A53A-9CB7-48A0-967B-FB8919AF8FC7}.Release|x64.ActiveCfg = Release|Any CPU 83 | {2381A53A-9CB7-48A0-967B-FB8919AF8FC7}.Release|x64.Build.0 = Release|Any CPU 84 | {2381A53A-9CB7-48A0-967B-FB8919AF8FC7}.Release|x86.ActiveCfg = Release|Any CPU 85 | {2381A53A-9CB7-48A0-967B-FB8919AF8FC7}.Release|x86.Build.0 = Release|Any CPU 86 | {BF8A998F-5014-4043-BAF0-056B665A29A5}.Ad-Hoc|Any CPU.ActiveCfg = Release|Any CPU 87 | {BF8A998F-5014-4043-BAF0-056B665A29A5}.Ad-Hoc|Any CPU.Build.0 = Release|Any CPU 88 | {BF8A998F-5014-4043-BAF0-056B665A29A5}.Ad-Hoc|ARM.ActiveCfg = Release|Any CPU 89 | {BF8A998F-5014-4043-BAF0-056B665A29A5}.Ad-Hoc|ARM.Build.0 = Release|Any CPU 90 | {BF8A998F-5014-4043-BAF0-056B665A29A5}.Ad-Hoc|iPhone.ActiveCfg = Release|Any CPU 91 | {BF8A998F-5014-4043-BAF0-056B665A29A5}.Ad-Hoc|iPhone.Build.0 = Release|Any CPU 92 | {BF8A998F-5014-4043-BAF0-056B665A29A5}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Release|Any CPU 93 | {BF8A998F-5014-4043-BAF0-056B665A29A5}.Ad-Hoc|iPhoneSimulator.Build.0 = Release|Any CPU 94 | {BF8A998F-5014-4043-BAF0-056B665A29A5}.Ad-Hoc|x64.ActiveCfg = Release|Any CPU 95 | {BF8A998F-5014-4043-BAF0-056B665A29A5}.Ad-Hoc|x64.Build.0 = Release|Any CPU 96 | {BF8A998F-5014-4043-BAF0-056B665A29A5}.Ad-Hoc|x86.ActiveCfg = Release|Any CPU 97 | {BF8A998F-5014-4043-BAF0-056B665A29A5}.Ad-Hoc|x86.Build.0 = Release|Any CPU 98 | {BF8A998F-5014-4043-BAF0-056B665A29A5}.AppStore|Any CPU.ActiveCfg = Release|Any CPU 99 | {BF8A998F-5014-4043-BAF0-056B665A29A5}.AppStore|Any CPU.Build.0 = Release|Any CPU 100 | {BF8A998F-5014-4043-BAF0-056B665A29A5}.AppStore|ARM.ActiveCfg = Release|Any CPU 101 | {BF8A998F-5014-4043-BAF0-056B665A29A5}.AppStore|ARM.Build.0 = Release|Any CPU 102 | {BF8A998F-5014-4043-BAF0-056B665A29A5}.AppStore|iPhone.ActiveCfg = Release|Any CPU 103 | {BF8A998F-5014-4043-BAF0-056B665A29A5}.AppStore|iPhone.Build.0 = Release|Any CPU 104 | {BF8A998F-5014-4043-BAF0-056B665A29A5}.AppStore|iPhoneSimulator.ActiveCfg = Release|Any CPU 105 | {BF8A998F-5014-4043-BAF0-056B665A29A5}.AppStore|iPhoneSimulator.Build.0 = Release|Any CPU 106 | {BF8A998F-5014-4043-BAF0-056B665A29A5}.AppStore|x64.ActiveCfg = Release|Any CPU 107 | {BF8A998F-5014-4043-BAF0-056B665A29A5}.AppStore|x64.Build.0 = Release|Any CPU 108 | {BF8A998F-5014-4043-BAF0-056B665A29A5}.AppStore|x86.ActiveCfg = Release|Any CPU 109 | {BF8A998F-5014-4043-BAF0-056B665A29A5}.AppStore|x86.Build.0 = Release|Any CPU 110 | {BF8A998F-5014-4043-BAF0-056B665A29A5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 111 | {BF8A998F-5014-4043-BAF0-056B665A29A5}.Debug|Any CPU.Build.0 = Debug|Any CPU 112 | {BF8A998F-5014-4043-BAF0-056B665A29A5}.Debug|ARM.ActiveCfg = Debug|Any CPU 113 | {BF8A998F-5014-4043-BAF0-056B665A29A5}.Debug|ARM.Build.0 = Debug|Any CPU 114 | {BF8A998F-5014-4043-BAF0-056B665A29A5}.Debug|iPhone.ActiveCfg = Debug|Any CPU 115 | {BF8A998F-5014-4043-BAF0-056B665A29A5}.Debug|iPhone.Build.0 = Debug|Any CPU 116 | {BF8A998F-5014-4043-BAF0-056B665A29A5}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU 117 | {BF8A998F-5014-4043-BAF0-056B665A29A5}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU 118 | {BF8A998F-5014-4043-BAF0-056B665A29A5}.Debug|x64.ActiveCfg = Debug|Any CPU 119 | {BF8A998F-5014-4043-BAF0-056B665A29A5}.Debug|x64.Build.0 = Debug|Any CPU 120 | {BF8A998F-5014-4043-BAF0-056B665A29A5}.Debug|x86.ActiveCfg = Debug|Any CPU 121 | {BF8A998F-5014-4043-BAF0-056B665A29A5}.Debug|x86.Build.0 = Debug|Any CPU 122 | {BF8A998F-5014-4043-BAF0-056B665A29A5}.Release|Any CPU.ActiveCfg = Release|Any CPU 123 | {BF8A998F-5014-4043-BAF0-056B665A29A5}.Release|Any CPU.Build.0 = Release|Any CPU 124 | {BF8A998F-5014-4043-BAF0-056B665A29A5}.Release|ARM.ActiveCfg = Release|Any CPU 125 | {BF8A998F-5014-4043-BAF0-056B665A29A5}.Release|ARM.Build.0 = Release|Any CPU 126 | {BF8A998F-5014-4043-BAF0-056B665A29A5}.Release|iPhone.ActiveCfg = Release|Any CPU 127 | {BF8A998F-5014-4043-BAF0-056B665A29A5}.Release|iPhone.Build.0 = Release|Any CPU 128 | {BF8A998F-5014-4043-BAF0-056B665A29A5}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU 129 | {BF8A998F-5014-4043-BAF0-056B665A29A5}.Release|iPhoneSimulator.Build.0 = Release|Any CPU 130 | {BF8A998F-5014-4043-BAF0-056B665A29A5}.Release|x64.ActiveCfg = Release|Any CPU 131 | {BF8A998F-5014-4043-BAF0-056B665A29A5}.Release|x64.Build.0 = Release|Any CPU 132 | {BF8A998F-5014-4043-BAF0-056B665A29A5}.Release|x86.ActiveCfg = Release|Any CPU 133 | {BF8A998F-5014-4043-BAF0-056B665A29A5}.Release|x86.Build.0 = Release|Any CPU 134 | EndGlobalSection 135 | GlobalSection(SolutionProperties) = preSolution 136 | HideSolutionNode = FALSE 137 | EndGlobalSection 138 | GlobalSection(ExtensibilityGlobals) = postSolution 139 | SolutionGuid = {9A3CC57E-E869-427C-9FDE-C135E7DE035F} 140 | EndGlobalSection 141 | EndGlobal 142 | -------------------------------------------------------------------------------- /src/WeatherApp/WeatherApp.WPF/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/WeatherApp/WeatherApp.WPF/App.xaml: -------------------------------------------------------------------------------- 1 |  5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/WeatherApp/WeatherApp.WPF/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | namespace WeatherApp.WPF 4 | { 5 | public partial class App : Application 6 | { 7 | } 8 | } -------------------------------------------------------------------------------- /src/WeatherApp/WeatherApp.WPF/Images/cloud.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsuarezruiz/xamarin-forms-wpf-weather-sample/254f2f935a26ac9bb00bd587d49c03145762ac5b/src/WeatherApp/WeatherApp.WPF/Images/cloud.png -------------------------------------------------------------------------------- /src/WeatherApp/WeatherApp.WPF/Images/clouds-background.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsuarezruiz/xamarin-forms-wpf-weather-sample/254f2f935a26ac9bb00bd587d49c03145762ac5b/src/WeatherApp/WeatherApp.WPF/Images/clouds-background.jpg -------------------------------------------------------------------------------- /src/WeatherApp/WeatherApp.WPF/Images/moon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsuarezruiz/xamarin-forms-wpf-weather-sample/254f2f935a26ac9bb00bd587d49c03145762ac5b/src/WeatherApp/WeatherApp.WPF/Images/moon.png -------------------------------------------------------------------------------- /src/WeatherApp/WeatherApp.WPF/Images/rain-background.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsuarezruiz/xamarin-forms-wpf-weather-sample/254f2f935a26ac9bb00bd587d49c03145762ac5b/src/WeatherApp/WeatherApp.WPF/Images/rain-background.jpg -------------------------------------------------------------------------------- /src/WeatherApp/WeatherApp.WPF/Images/rain.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsuarezruiz/xamarin-forms-wpf-weather-sample/254f2f935a26ac9bb00bd587d49c03145762ac5b/src/WeatherApp/WeatherApp.WPF/Images/rain.png -------------------------------------------------------------------------------- /src/WeatherApp/WeatherApp.WPF/Images/reload.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsuarezruiz/xamarin-forms-wpf-weather-sample/254f2f935a26ac9bb00bd587d49c03145762ac5b/src/WeatherApp/WeatherApp.WPF/Images/reload.png -------------------------------------------------------------------------------- /src/WeatherApp/WeatherApp.WPF/Images/sun-background.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsuarezruiz/xamarin-forms-wpf-weather-sample/254f2f935a26ac9bb00bd587d49c03145762ac5b/src/WeatherApp/WeatherApp.WPF/Images/sun-background.jpg -------------------------------------------------------------------------------- /src/WeatherApp/WeatherApp.WPF/Images/sun.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsuarezruiz/xamarin-forms-wpf-weather-sample/254f2f935a26ac9bb00bd587d49c03145762ac5b/src/WeatherApp/WeatherApp.WPF/Images/sun.png -------------------------------------------------------------------------------- /src/WeatherApp/WeatherApp.WPF/MainWindow.xaml: -------------------------------------------------------------------------------- 1 |  10 | 11 | -------------------------------------------------------------------------------- /src/WeatherApp/WeatherApp.WPF/MainWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using Xamarin.Forms.Platform.WPF; 2 | 3 | namespace WeatherApp.WPF 4 | { 5 | public partial class MainWindow : FormsApplicationPage 6 | { 7 | public MainWindow() 8 | { 9 | InitializeComponent(); 10 | Xamarin.Forms.Forms.Init(); 11 | LoadApplication(new WeatherApp.App()); 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /src/WeatherApp/WeatherApp.WPF/OpenTK.dll.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/WeatherApp/WeatherApp.WPF/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Resources; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | using System.Windows; 6 | 7 | // General Information about an assembly is controlled through the following 8 | // set of attributes. Change these attribute values to modify the information 9 | // associated with an assembly. 10 | [assembly: AssemblyTitle("WeatherApp.WPF")] 11 | [assembly: AssemblyDescription("")] 12 | [assembly: AssemblyConfiguration("")] 13 | [assembly: AssemblyCompany("")] 14 | [assembly: AssemblyProduct("WeatherApp.WPF")] 15 | [assembly: AssemblyCopyright("Copyright © 2017")] 16 | [assembly: AssemblyTrademark("")] 17 | [assembly: AssemblyCulture("")] 18 | 19 | // Setting ComVisible to false makes the types in this assembly not visible 20 | // to COM components. If you need to access a type in this assembly from 21 | // COM, set the ComVisible attribute to true on that type. 22 | [assembly: ComVisible(false)] 23 | 24 | //In order to begin building localizable applications, set 25 | //CultureYouAreCodingWith in your .csproj file 26 | //inside a . For example, if you are using US english 27 | //in your source files, set the to en-US. Then uncomment 28 | //the NeutralResourceLanguage attribute below. Update the "en-US" in 29 | //the line below to match the UICulture setting in the project file. 30 | 31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] 32 | 33 | 34 | [assembly: ThemeInfo( 35 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 36 | //(used if a resource is not found in the page, 37 | // or application resource dictionaries) 38 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 39 | //(used if a resource is not found in the page, 40 | // app, or any theme specific resource dictionaries) 41 | )] 42 | 43 | 44 | // Version information for an assembly consists of the following four values: 45 | // 46 | // Major Version 47 | // Minor Version 48 | // Build Number 49 | // Revision 50 | // 51 | // You can specify all the values or you can default the Build and Revision Numbers 52 | // by using the '*' as shown below: 53 | // [assembly: AssemblyVersion("1.0.*")] 54 | [assembly: AssemblyVersion("1.0.0.0")] 55 | [assembly: AssemblyFileVersion("1.0.0.0")] 56 | -------------------------------------------------------------------------------- /src/WeatherApp/WeatherApp.WPF/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Este código fue generado por una herramienta. 4 | // Versión de runtime:4.0.30319.42000 5 | // 6 | // Los cambios en este archivo podrían causar un comportamiento incorrecto y se perderán si 7 | // se vuelve a generar el código. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace WeatherApp.WPF.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// Clase de recurso fuertemente tipado, para buscar cadenas traducidas, etc. 17 | /// 18 | // StronglyTypedResourceBuilder generó automáticamente esta clase 19 | // a través de una herramienta como ResGen o Visual Studio. 20 | // Para agregar o quitar un miembro, edite el archivo .ResX y, a continuación, vuelva a ejecutar ResGen 21 | // con la opción /str o recompile su proyecto de VS. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Devuelve la instancia de ResourceManager almacenada en caché utilizada por esta clase. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WeatherApp.WPF.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Reemplaza la propiedad CurrentUICulture del subproceso actual para todas las 51 | /// búsquedas de recursos mediante esta clase de recurso fuertemente tipado. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/WeatherApp/WeatherApp.WPF/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /src/WeatherApp/WeatherApp.WPF/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Este código fue generado por una herramienta. 4 | // Versión de runtime:4.0.30319.42000 5 | // 6 | // Los cambios en este archivo podrían causar un comportamiento incorrecto y se perderán si 7 | // se vuelve a generar el código. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace WeatherApp.WPF.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.8.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/WeatherApp/WeatherApp.WPF/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/WeatherApp/WeatherApp.WPF/WeatherApp.WPF.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | Debug 7 | AnyCPU 8 | {BF8A998F-5014-4043-BAF0-056B665A29A5} 9 | WinExe 10 | WeatherApp.WPF 11 | WeatherApp.WPF 12 | v4.7.1 13 | 512 14 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 15 | 4 16 | true 17 | 18 | 19 | 20 | 21 | 22 | AnyCPU 23 | true 24 | full 25 | false 26 | bin\Debug\ 27 | DEBUG;TRACE 28 | prompt 29 | 4 30 | 31 | 32 | AnyCPU 33 | pdbonly 34 | true 35 | bin\Release\ 36 | TRACE 37 | prompt 38 | 4 39 | 40 | 41 | 42 | ..\..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll 43 | 44 | 45 | ..\..\packages\OpenTK.2.0.0\lib\net20\OpenTK.dll 46 | 47 | 48 | ..\..\packages\OpenTK.GLControl.1.1.2349.61993\lib\NET40\OpenTK.GLControl.dll 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 4.0 60 | 61 | 62 | 63 | 64 | 65 | ..\..\packages\WpfLightToolkit.1.0.3\lib\net45\WpfLightToolkit.dll 66 | 67 | 68 | ..\..\packages\Xamarin.Forms.3.1.0.697729\lib\netstandard2.0\Xamarin.Forms.Core.dll 69 | 70 | 71 | ..\..\packages\Xamarin.Forms.3.1.0.697729\lib\netstandard2.0\Xamarin.Forms.Platform.dll 72 | 73 | 74 | ..\..\packages\Xamarin.Forms.Platform.WPF.3.1.0.697729\lib\net45\Xamarin.Forms.Platform.WPF.dll 75 | 76 | 77 | ..\..\packages\Xamarin.Forms.3.1.0.697729\lib\netstandard2.0\Xamarin.Forms.Xaml.dll 78 | 79 | 80 | 81 | 82 | MSBuild:Compile 83 | Designer 84 | 85 | 86 | MSBuild:Compile 87 | Designer 88 | 89 | 90 | App.xaml 91 | Code 92 | 93 | 94 | MainWindow.xaml 95 | Code 96 | 97 | 98 | 99 | 100 | Code 101 | 102 | 103 | True 104 | True 105 | Resources.resx 106 | 107 | 108 | True 109 | Settings.settings 110 | True 111 | 112 | 113 | ResXFileCodeGenerator 114 | Resources.Designer.cs 115 | 116 | 117 | 118 | Designer 119 | 120 | 121 | SettingsSingleFileGenerator 122 | Settings.Designer.cs 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | {2381a53a-9cb7-48a0-967b-fb8919af8fc7} 131 | WeatherApp 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | Este proyecto hace referencia a los paquetes NuGet que faltan en este equipo. Use la restauración de paquetes NuGet para descargarlos. Para obtener más información, consulte http://go.microsoft.com/fwlink/?LinkID=322105. El archivo que falta es {0}. 148 | 149 | 150 | 151 | 152 | 153 | -------------------------------------------------------------------------------- /src/WeatherApp/WeatherApp.WPF/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/WeatherApp/WeatherApp/App.xaml: -------------------------------------------------------------------------------- 1 |  2 | 6 | 7 | 8 | 9 | 10 | #353186 11 | #FFFFFF 12 | #000000 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/WeatherApp/WeatherApp/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using WeatherApp.Views; 2 | using Xamarin.Forms; 3 | 4 | namespace WeatherApp 5 | { 6 | public partial class App : Application 7 | { 8 | public App() 9 | { 10 | InitializeComponent(); 11 | 12 | MainPage = new CustomNavigationPage(new WeatherView()); 13 | } 14 | 15 | protected override void OnStart() 16 | { 17 | // Handle when your app starts 18 | } 19 | 20 | protected override void OnSleep() 21 | { 22 | // Handle when your app sleeps 23 | } 24 | 25 | protected override void OnResume() 26 | { 27 | // Handle when your app resumes 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/WeatherApp/WeatherApp/AppSettings.cs: -------------------------------------------------------------------------------- 1 | namespace WeatherApp 2 | { 3 | public class AppSettings 4 | { 5 | public static string Location = "Sevilla"; 6 | public static bool IsImperial = false; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/WeatherApp/WeatherApp/Controls/HorizontalList/HorizontalList.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using System.Windows.Input; 5 | using Xamarin.Forms; 6 | 7 | namespace WeatherApp.Controls 8 | { 9 | public class HorizontalList : Grid 10 | { 11 | private ICommand _innerSelectedCommand; 12 | private readonly ScrollView _scrollView; 13 | private readonly StackLayout _itemsStackLayout; 14 | 15 | public event EventHandler SelectedItemChanged; 16 | 17 | public StackOrientation ListOrientation { get; set; } 18 | 19 | public double Spacing { get; set; } 20 | 21 | public static readonly BindableProperty SelectedCommandProperty = 22 | BindableProperty.Create("SelectedCommand", typeof(ICommand), typeof(HorizontalList), null); 23 | 24 | public static readonly BindableProperty ItemsSourceProperty = 25 | BindableProperty.Create("ItemsSource", typeof(IEnumerable), typeof(HorizontalList), default(IEnumerable), BindingMode.TwoWay, propertyChanged: ItemsSourceChanged); 26 | 27 | public static readonly BindableProperty SelectedItemProperty = 28 | BindableProperty.Create("SelectedItem", typeof(object), typeof(HorizontalList), null, BindingMode.TwoWay, propertyChanged: OnSelectedItemChanged); 29 | 30 | public static readonly BindableProperty ItemTemplateProperty = 31 | BindableProperty.Create("ItemTemplate", typeof(DataTemplate), typeof(HorizontalList), default(DataTemplate)); 32 | 33 | public ICommand SelectedCommand 34 | { 35 | get { return (ICommand)GetValue(SelectedCommandProperty); } 36 | set { SetValue(SelectedCommandProperty, value); } 37 | } 38 | 39 | public IEnumerable ItemsSource 40 | { 41 | get { return (IEnumerable)GetValue(ItemsSourceProperty); } 42 | set { SetValue(ItemsSourceProperty, value); } 43 | } 44 | 45 | public object SelectedItem 46 | { 47 | get { return (object)GetValue(SelectedItemProperty); } 48 | set { SetValue(SelectedItemProperty, value); } 49 | } 50 | 51 | public DataTemplate ItemTemplate 52 | { 53 | get { return (DataTemplate)GetValue(ItemTemplateProperty); } 54 | set { SetValue(ItemTemplateProperty, value); } 55 | } 56 | 57 | private static void ItemsSourceChanged(BindableObject bindable, object oldValue, object newValue) 58 | { 59 | var itemsLayout = (HorizontalList)bindable; 60 | itemsLayout.SetItems(); 61 | } 62 | 63 | public HorizontalList() 64 | { 65 | Spacing = 6; 66 | _scrollView = new ScrollView(); 67 | _itemsStackLayout = new StackLayout 68 | { 69 | BackgroundColor = BackgroundColor, 70 | Padding = Padding, 71 | Spacing = Spacing, 72 | HorizontalOptions = LayoutOptions.FillAndExpand 73 | }; 74 | 75 | _scrollView.BackgroundColor = BackgroundColor; 76 | _scrollView.Content = _itemsStackLayout; 77 | Children.Add(_scrollView); 78 | } 79 | 80 | protected virtual void SetItems() 81 | { 82 | _itemsStackLayout.Children.Clear(); 83 | _itemsStackLayout.Spacing = Spacing; 84 | 85 | _innerSelectedCommand = new Command(view => 86 | { 87 | SelectedItem = view.BindingContext; 88 | SelectedItem = null; // Allowing item second time selection 89 | }); 90 | 91 | _itemsStackLayout.Orientation = ListOrientation; 92 | _scrollView.Orientation = ListOrientation == StackOrientation.Horizontal 93 | ? ScrollOrientation.Horizontal 94 | : ScrollOrientation.Vertical; 95 | 96 | if (ItemsSource == null) 97 | { 98 | return; 99 | } 100 | 101 | foreach (var item in ItemsSource) 102 | { 103 | _itemsStackLayout.Children.Add(GetItemView(item)); 104 | } 105 | 106 | _itemsStackLayout.BackgroundColor = BackgroundColor; 107 | SelectedItem = null; 108 | } 109 | 110 | protected virtual View GetItemView(object item) 111 | { 112 | var content = ItemTemplate.CreateContent(); 113 | var view = content as View; 114 | 115 | if (view == null) 116 | { 117 | return null; 118 | } 119 | 120 | view.BindingContext = item; 121 | 122 | var gesture = new TapGestureRecognizer 123 | { 124 | Command = _innerSelectedCommand, 125 | CommandParameter = view 126 | }; 127 | 128 | AddGesture(view, gesture); 129 | 130 | return view; 131 | } 132 | 133 | private void AddGesture(View view, TapGestureRecognizer gesture) 134 | { 135 | view.GestureRecognizers.Add(gesture); 136 | 137 | var layout = view as Layout; 138 | 139 | if (layout == null) 140 | { 141 | return; 142 | } 143 | 144 | foreach (var child in layout.Children) 145 | { 146 | AddGesture(child, gesture); 147 | } 148 | } 149 | 150 | private static void OnSelectedItemChanged(BindableObject bindable, object oldValue, object newValue) 151 | { 152 | var itemsView = (HorizontalList)bindable; 153 | if (newValue == oldValue && newValue != null) 154 | { 155 | return; 156 | } 157 | 158 | itemsView.SelectedItemChanged?.Invoke(itemsView, EventArgs.Empty); 159 | 160 | if (itemsView.SelectedCommand?.CanExecute(newValue) ?? false) 161 | { 162 | itemsView.SelectedCommand?.Execute(newValue); 163 | } 164 | } 165 | } 166 | } -------------------------------------------------------------------------------- /src/WeatherApp/WeatherApp/Converters/BackgroundConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using Xamarin.Forms; 4 | 5 | namespace WeatherApp.Converters 6 | { 7 | public class BackgroundConverter : IValueConverter 8 | { 9 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 10 | { 11 | if (value == null) 12 | return string.Empty; 13 | 14 | var condition = value.ToString(); 15 | 16 | if (condition.Contains("cloud")) 17 | { 18 | if (Device.RuntimePlatform == Device.WPF) 19 | return "Images/clouds-background.jpg"; 20 | else if (Device.RuntimePlatform == Device.UWP) 21 | return "Assets/clouds-background.jpg"; 22 | else 23 | return "clouds-background.jpg"; 24 | } 25 | else if (condition.Contains("rain")) 26 | { 27 | if (Device.RuntimePlatform == Device.WPF) 28 | return "Images/rain-background.jpg"; 29 | else if (Device.RuntimePlatform == Device.UWP) 30 | return "Assets/rain-background.jpg"; 31 | else 32 | return "rain-background.jpg"; 33 | } 34 | else if (condition.Contains("sun") || (condition.Contains("clear sky"))) 35 | { 36 | if (Device.RuntimePlatform == Device.WPF) 37 | return "Images/sun-background.jpg"; 38 | else if (Device.RuntimePlatform == Device.UWP) 39 | return "Assets/sun-background.jpg"; 40 | else 41 | return "sun-background.jpg"; 42 | } 43 | else 44 | return string.Empty; 45 | } 46 | 47 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 48 | { 49 | return null; 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /src/WeatherApp/WeatherApp/Converters/IconConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using Xamarin.Forms; 4 | 5 | namespace WeatherApp.Converters 6 | { 7 | public class IconConverter : IValueConverter 8 | { 9 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 10 | { 11 | if (value == null) 12 | return string.Empty; 13 | 14 | var iconType = value.ToString(); 15 | 16 | switch(iconType) 17 | { 18 | case "01n": 19 | if(Device.RuntimePlatform == Device.WPF) 20 | return "Images/moon.png"; 21 | else if (Device.RuntimePlatform == Device.UWP) 22 | return "Assets/moon.png"; 23 | else 24 | return "moon.png"; 25 | case "01d": 26 | if (Device.RuntimePlatform == Device.WPF) 27 | return "Images/sun.png"; 28 | else if (Device.RuntimePlatform == Device.UWP) 29 | return "Assets/sun.png"; 30 | else 31 | return "sun.png"; 32 | case "02n": 33 | case "02d": 34 | case "04d": 35 | if (Device.RuntimePlatform == Device.WPF) 36 | return "Images/cloud.png"; 37 | else if (Device.RuntimePlatform == Device.UWP) 38 | return "Assets/cloud.png"; 39 | else 40 | return "cloud.png"; 41 | case "10d": 42 | if (Device.RuntimePlatform == Device.WPF) 43 | return "Images/rain.png"; 44 | else if (Device.RuntimePlatform == Device.UWP) 45 | return "Assets/rain.png"; 46 | else 47 | return "rain.png"; 48 | default: 49 | if (Device.RuntimePlatform == Device.WPF) 50 | return "Images/cloud.png"; 51 | else if (Device.RuntimePlatform == Device.UWP) 52 | return "Assets/cloud.png"; 53 | else 54 | return "cloud.png"; 55 | } 56 | } 57 | 58 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 59 | { 60 | return null; 61 | } 62 | } 63 | } -------------------------------------------------------------------------------- /src/WeatherApp/WeatherApp/Converters/InverseBoolConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using Xamarin.Forms; 4 | 5 | namespace WeatherApp.Converters 6 | { 7 | public class InverseBoolConverter : IValueConverter 8 | { 9 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 10 | { 11 | if (!(value is bool)) 12 | { 13 | throw new InvalidOperationException("The target must be a boolean"); 14 | } 15 | 16 | return !(bool)value; 17 | } 18 | 19 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 20 | { 21 | return null; 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /src/WeatherApp/WeatherApp/Models/Weather.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using System; 3 | using System.Collections.Generic; 4 | 5 | namespace WeatherApp.Models 6 | { 7 | public class Coord 8 | { 9 | [JsonProperty("lon")] 10 | public double Longitude { get; set; } = 0; 11 | 12 | [JsonProperty("lat")] 13 | public double Latitude { get; set; } = 0; 14 | } 15 | 16 | public class Sys 17 | { 18 | 19 | [JsonProperty("country")] 20 | public string Country { get; set; } = string.Empty; 21 | } 22 | 23 | public class Weather 24 | { 25 | [JsonProperty("id")] 26 | public int Id { get; set; } = 0; 27 | 28 | [JsonProperty("main")] 29 | public string Main { get; set; } = string.Empty; 30 | 31 | [JsonProperty("description")] 32 | public string Description { get; set; } = string.Empty; 33 | 34 | [JsonProperty("icon")] 35 | public string Icon { get; set; } = string.Empty; 36 | } 37 | 38 | public class Main 39 | { 40 | [JsonProperty("temp")] 41 | public double Temperature { get; set; } = 0; 42 | [JsonProperty("pressure")] 43 | public double Pressure { get; set; } = 0; 44 | 45 | [JsonProperty("humidity")] 46 | public double Humidity { get; set; } = 0; 47 | [JsonProperty("temp_min")] 48 | public double MinTemperature { get; set; } = 0; 49 | 50 | [JsonProperty("temp_max")] 51 | public double MaxTemperature { get; set; } = 0; 52 | } 53 | 54 | public class Wind 55 | { 56 | [JsonProperty("speed")] 57 | public double Speed { get; set; } = 0; 58 | 59 | [JsonProperty("deg")] 60 | public double WindDirectionDegrees { get; set; } = 0; 61 | 62 | } 63 | 64 | public class Clouds 65 | { 66 | 67 | [JsonProperty("all")] 68 | public int CloudinessPercent { get; set; } = 0; 69 | } 70 | 71 | public class WeatherRoot 72 | { 73 | [JsonProperty("coord")] 74 | public Coord Coordinates { get; set; } = new Coord(); 75 | 76 | [JsonProperty("sys")] 77 | public Sys System { get; set; } = new Sys(); 78 | 79 | [JsonProperty("weather")] 80 | public List Weather { get; set; } = new List(); 81 | 82 | [JsonProperty("main")] 83 | public Main MainWeather { get; set; } = new Main(); 84 | 85 | [JsonProperty("wind")] 86 | public Wind Wind { get; set; } = new Wind(); 87 | 88 | [JsonProperty("clouds")] 89 | public Clouds Clouds { get; set; } = new Clouds(); 90 | 91 | [JsonProperty("id")] 92 | public int CityId { get; set; } = 0; 93 | 94 | [JsonProperty("name")] 95 | public string Name { get; set; } = string.Empty; 96 | 97 | [JsonProperty("dt_txt")] 98 | public string Date { get; set; } = string.Empty; 99 | 100 | [JsonIgnore] 101 | public string DisplayDate => DateTime.Parse(Date).Hour.ToString(); 102 | [JsonIgnore] 103 | public string DisplayTemp => $"{MainWeather?.Temperature ?? 0}° {Weather?[0]?.Main ?? string.Empty}"; 104 | [JsonIgnore] 105 | public string DisplayIcon => $"http://openweathermap.org/img/w/{Weather?[0]?.Icon}.png"; 106 | [JsonIgnore] 107 | public string Icon => Weather?[0]?.Icon; 108 | } 109 | 110 | public class WeatherForecastRoot 111 | { 112 | [JsonProperty("city")] 113 | public City City { get; set; } 114 | [JsonProperty("cod")] 115 | public string Vod { get; set; } 116 | [JsonProperty("message")] 117 | public double Message { get; set; } 118 | [JsonProperty("cnt")] 119 | public int Cnt { get; set; } 120 | [JsonProperty("list")] 121 | public List Items { get; set; } 122 | 123 | } 124 | 125 | public class City 126 | { 127 | [JsonProperty("id")] 128 | public int Id { get; set; } 129 | [JsonProperty("name")] 130 | public string Name { get; set; } 131 | [JsonProperty("coord")] 132 | public Coord Coord { get; set; } 133 | [JsonProperty("country")] 134 | public string Country { get; set; } 135 | [JsonProperty("population")] 136 | public int Population { get; set; } 137 | [JsonProperty("sys")] 138 | public Sys Sys { get; set; } 139 | } 140 | } -------------------------------------------------------------------------------- /src/WeatherApp/WeatherApp/Services/WeatherService.cs: -------------------------------------------------------------------------------- 1 | using System.Net.Http; 2 | using System.Threading.Tasks; 3 | using WeatherApp.Models; 4 | using static Newtonsoft.Json.JsonConvert; 5 | 6 | namespace WeatherApp.Services 7 | { 8 | public enum Units 9 | { 10 | Imperial, 11 | Metric 12 | } 13 | 14 | public class WeatherService 15 | { 16 | const string WeatherCoordinatesUri = "http://api.openweathermap.org/data/2.5/weather?lat={0}&lon={1}&units={2}&appid=fc9f6c524fc093759cd28d41fda89a1b"; 17 | const string WeatherCityUri = "http://api.openweathermap.org/data/2.5/weather?q={0}&units={1}&appid=fc9f6c524fc093759cd28d41fda89a1b"; 18 | const string ForecaseUri = "http://api.openweathermap.org/data/2.5/forecast?id={0}&units={1}&appid=fc9f6c524fc093759cd28d41fda89a1b"; 19 | 20 | private static WeatherService _instance; 21 | 22 | public static WeatherService Instance 23 | { 24 | get 25 | { 26 | if (_instance == null) 27 | _instance = new WeatherService(); 28 | 29 | return _instance; 30 | } 31 | } 32 | 33 | public async Task GetWeatherAsync(double latitude, double longitude, Units units = Units.Imperial) 34 | { 35 | using (var client = new HttpClient()) 36 | { 37 | var url = string.Format(WeatherCoordinatesUri, latitude, longitude, units.ToString().ToLower()); 38 | var json = await client.GetStringAsync(url); 39 | 40 | if (string.IsNullOrWhiteSpace(json)) 41 | return null; 42 | 43 | return DeserializeObject(json); 44 | } 45 | 46 | } 47 | 48 | public async Task GetWeatherAsync(string city, Units units = Units.Imperial) 49 | { 50 | using (var client = new HttpClient()) 51 | { 52 | var url = string.Format(WeatherCityUri, city, units.ToString().ToLower()); 53 | var json = await client.GetStringAsync(url); 54 | 55 | if (string.IsNullOrWhiteSpace(json)) 56 | return null; 57 | 58 | return DeserializeObject(json); 59 | } 60 | 61 | } 62 | 63 | public async Task GetForecast(int id, Units units = Units.Imperial) 64 | { 65 | using (var client = new HttpClient()) 66 | { 67 | var url = string.Format(ForecaseUri, id, units.ToString().ToLower()); 68 | var json = await client.GetStringAsync(url); 69 | 70 | if (string.IsNullOrWhiteSpace(json)) 71 | return null; 72 | 73 | return DeserializeObject(json); 74 | } 75 | 76 | } 77 | } 78 | } -------------------------------------------------------------------------------- /src/WeatherApp/WeatherApp/ViewModels/WeatherViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Threading.Tasks; 4 | using System.Windows.Input; 5 | using WeatherApp.Models; 6 | using WeatherApp.Services; 7 | using Xamarin.Forms; 8 | 9 | namespace WeatherApp.ViewModels 10 | { 11 | public class WeatherViewModel : BindableObject 12 | { 13 | private bool _isBusy; 14 | private string _temp; 15 | private string _condition; 16 | private WeatherForecastRoot _forecast; 17 | private ICommand _reloadCommand; 18 | 19 | public bool IsBusy 20 | { 21 | get { return _isBusy; } 22 | set 23 | { 24 | _isBusy = value; 25 | OnPropertyChanged(); 26 | } 27 | } 28 | 29 | public string Temp 30 | { 31 | get { return _temp; } 32 | set 33 | { 34 | _temp = value; 35 | OnPropertyChanged(); 36 | } 37 | } 38 | 39 | public string Condition 40 | { 41 | get { return _condition; } 42 | set 43 | { 44 | _condition = value; 45 | OnPropertyChanged(); 46 | } 47 | } 48 | 49 | public WeatherForecastRoot Forecast 50 | { 51 | get { return _forecast; } 52 | set 53 | { 54 | _forecast = value; 55 | OnPropertyChanged(); 56 | } 57 | } 58 | 59 | public ICommand ReloadCommand => 60 | _reloadCommand ?? 61 | (_reloadCommand = new Command(async () => await GetWeatherAsync())); 62 | 63 | public async Task GetWeatherAsync() 64 | { 65 | if (IsBusy) 66 | return; 67 | 68 | IsBusy = true; 69 | try 70 | { 71 | WeatherRoot weatherRoot = null; 72 | var units = AppSettings.IsImperial ? Units.Imperial : Units.Metric; 73 | weatherRoot = await WeatherService.Instance.GetWeatherAsync(AppSettings.Location.Trim(), units); 74 | Forecast = await WeatherService.Instance.GetForecast(weatherRoot.CityId, units); 75 | var unit = AppSettings.IsImperial ? "F" : "C"; 76 | Temp = $"{weatherRoot?.MainWeather?.Temperature ?? 0}°{unit}"; 77 | Condition = $"{weatherRoot.Name}: {weatherRoot?.Weather?[0]?.Description ?? string.Empty}"; 78 | } 79 | catch (Exception ex) 80 | { 81 | Temp = "Unable to get Weather"; 82 | Debug.WriteLine(ex.Message); 83 | } 84 | finally 85 | { 86 | IsBusy = false; 87 | } 88 | } 89 | } 90 | } -------------------------------------------------------------------------------- /src/WeatherApp/WeatherApp/Views/CustomNavigationPage.xaml: -------------------------------------------------------------------------------- 1 |  2 | 9 | -------------------------------------------------------------------------------- /src/WeatherApp/WeatherApp/Views/CustomNavigationPage.xaml.cs: -------------------------------------------------------------------------------- 1 | using Xamarin.Forms; 2 | 3 | namespace WeatherApp.Views 4 | { 5 | public partial class CustomNavigationPage : NavigationPage 6 | { 7 | public CustomNavigationPage() : base() 8 | { 9 | InitializeComponent(); 10 | } 11 | 12 | public CustomNavigationPage(Page root) : base(root) 13 | { 14 | InitializeComponent(); 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /src/WeatherApp/WeatherApp/Views/Templates/WeatherItemTemplate.xaml: -------------------------------------------------------------------------------- 1 |  2 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 19 | 20 | 21 | 24 | 25 | 26 | 27 | 28 | 29 | 42 | 43 | -------------------------------------------------------------------------------- /src/WeatherApp/WeatherApp/Views/Templates/WeatherItemTemplate.xaml.cs: -------------------------------------------------------------------------------- 1 | using Xamarin.Forms; 2 | 3 | namespace WeatherApp.Views.Templates 4 | { 5 | public partial class WeatherItemTemplate : ContentView 6 | { 7 | public WeatherItemTemplate() 8 | { 9 | InitializeComponent(); 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /src/WeatherApp/WeatherApp/Views/WeatherView.xaml: -------------------------------------------------------------------------------- 1 |  2 | 8 | 9 | 10 | 11 | 14 | 15 | 20 | 21 | 26 | 27 | 28 | 29 | 30 | 34 | 35 | 36 | 38 | 41 | 42 | 43 | 44 | 45 | 49 | 50 | 51 | 52 | 53 | 54 | 59 | 61 | 65 | 70 | 72 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /src/WeatherApp/WeatherApp/Views/WeatherView.xaml.cs: -------------------------------------------------------------------------------- 1 | using WeatherApp.ViewModels; 2 | using Xamarin.Forms; 3 | using Xamarin.Forms.Xaml; 4 | 5 | namespace WeatherApp.Views 6 | { 7 | public partial class WeatherView : ContentPage 8 | { 9 | public WeatherView() 10 | { 11 | InitializeComponent(); 12 | 13 | BindingContext = new WeatherViewModel(); 14 | } 15 | 16 | protected override async void OnAppearing() 17 | { 18 | if (BindingContext is WeatherViewModel) 19 | { 20 | await ((WeatherViewModel)BindingContext).GetWeatherAsync(); 21 | } 22 | 23 | base.OnAppearing(); 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /src/WeatherApp/WeatherApp/WeatherApp.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netstandard2.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | *.xaml 15 | 16 | 17 | 18 | --------------------------------------------------------------------------------