├── .gitattributes ├── .gitignore ├── ChatBoxbyWebView ├── ChatBoxbyWebView.sln └── ChatBoxbyWebView │ ├── App.xaml │ ├── App.xaml.cs │ ├── ApplicationInsights.config │ ├── Assets │ ├── LockScreenLogo.scale-200.png │ ├── SplashScreen.scale-200.png │ ├── Square150x150Logo.scale-200.png │ ├── Square44x44Logo.scale-200.png │ ├── Square44x44Logo.targetsize-24_altform-unplated.png │ ├── StoreLogo.png │ └── Wide310x150Logo.scale-200.png │ ├── ChatBoxTool.cs │ ├── ChatBoxbyWebView.csproj │ ├── MainPage.xaml │ ├── MainPage.xaml.cs │ ├── Package.appxmanifest │ ├── Properties │ ├── AssemblyInfo.cs │ └── Default.rd.xml │ ├── project.json │ └── project.lock.json ├── LoadingItemsInListView ├── LoadingItemsInListView.sln └── LoadingItemsInListView │ ├── App.xaml │ ├── App.xaml.cs │ ├── ApplicationInsights.config │ ├── Assets │ ├── LockScreenLogo.scale-200.png │ ├── SplashScreen.scale-200.png │ ├── Square150x150Logo.scale-200.png │ ├── Square44x44Logo.scale-200.png │ ├── Square44x44Logo.targetsize-24_altform-unplated.png │ ├── StoreLogo.png │ └── Wide310x150Logo.scale-200.png │ ├── BaseService.cs │ ├── BlogService.cs │ ├── CNBlog.cs │ ├── CNBlogItem.xaml │ ├── CNBlogItem.xaml.cs │ ├── CNBlogList.cs │ ├── LoadingItemsInListView.csproj │ ├── MainPage.xaml │ ├── MainPage.xaml.cs │ ├── Package.appxmanifest │ ├── Properties │ ├── AssemblyInfo.cs │ └── Default.rd.xml │ ├── project.json │ └── project.lock.json └── README.md /.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 | ################# 2 | ## Eclipse 3 | ################# 4 | 5 | *.pydevproject 6 | .project 7 | .metadata 8 | bin/ 9 | tmp/ 10 | *.tmp 11 | *.bak 12 | *.swp 13 | *~.nib 14 | local.properties 15 | .classpath 16 | .settings/ 17 | .loadpath 18 | 19 | # External tool builders 20 | .externalToolBuilders/ 21 | 22 | # Locally stored "Eclipse launch configurations" 23 | *.launch 24 | 25 | # CDT-specific 26 | .cproject 27 | 28 | # PDT-specific 29 | .buildpath 30 | 31 | 32 | ################# 33 | ## Visual Studio 34 | ################# 35 | 36 | ## Ignore Visual Studio temporary files, build results, and 37 | ## files generated by popular Visual Studio add-ons. 38 | 39 | # User-specific files 40 | *.suo 41 | *.user 42 | *.sln.docstates 43 | 44 | # Build results 45 | 46 | [Dd]ebug/ 47 | [Rr]elease/ 48 | x64/ 49 | build/ 50 | [Bb]in/ 51 | [Oo]bj/ 52 | 53 | # MSTest test Results 54 | [Tt]est[Rr]esult*/ 55 | [Bb]uild[Ll]og.* 56 | 57 | *_i.c 58 | *_p.c 59 | *.ilk 60 | *.meta 61 | *.obj 62 | *.pch 63 | *.pdb 64 | *.pgc 65 | *.pgd 66 | *.rsp 67 | *.sbr 68 | *.tlb 69 | *.tli 70 | *.tlh 71 | *.tmp 72 | *.tmp_proj 73 | *.log 74 | *.vspscc 75 | *.vssscc 76 | .builds 77 | *.pidb 78 | *.log 79 | *.scc 80 | 81 | # Visual C++ cache files 82 | ipch/ 83 | *.aps 84 | *.ncb 85 | *.opensdf 86 | *.sdf 87 | *.cachefile 88 | 89 | # Visual Studio profiler 90 | *.psess 91 | *.vsp 92 | *.vspx 93 | 94 | # Guidance Automation Toolkit 95 | *.gpState 96 | 97 | # ReSharper is a .NET coding add-in 98 | _ReSharper*/ 99 | *.[Rr]e[Ss]harper 100 | 101 | # TeamCity is a build add-in 102 | _TeamCity* 103 | 104 | # DotCover is a Code Coverage Tool 105 | *.dotCover 106 | 107 | # NCrunch 108 | *.ncrunch* 109 | .*crunch*.local.xml 110 | 111 | # Installshield output folder 112 | [Ee]xpress/ 113 | 114 | # DocProject is a documentation generator add-in 115 | DocProject/buildhelp/ 116 | DocProject/Help/*.HxT 117 | DocProject/Help/*.HxC 118 | DocProject/Help/*.hhc 119 | DocProject/Help/*.hhk 120 | DocProject/Help/*.hhp 121 | DocProject/Help/Html2 122 | DocProject/Help/html 123 | 124 | # Click-Once directory 125 | publish/ 126 | 127 | # Publish Web Output 128 | *.Publish.xml 129 | *.pubxml 130 | *.publishproj 131 | 132 | # NuGet Packages Directory 133 | ## TODO: If you have NuGet Package Restore enabled, uncomment the next line 134 | #packages/ 135 | 136 | # Windows Azure Build Output 137 | csx 138 | *.build.csdef 139 | 140 | # Windows Store app package directory 141 | AppPackages/ 142 | 143 | # Others 144 | sql/ 145 | *.Cache 146 | ClientBin/ 147 | [Ss]tyle[Cc]op.* 148 | ~$* 149 | *~ 150 | *.dbmdl 151 | *.[Pp]ublish.xml 152 | *.pfx 153 | *.publishsettings 154 | 155 | # RIA/Silverlight projects 156 | Generated_Code/ 157 | 158 | # Backup & report files from converting an old project file to a newer 159 | # Visual Studio version. Backup files are not needed, because we have git ;-) 160 | _UpgradeReport_Files/ 161 | Backup*/ 162 | UpgradeLog*.XML 163 | UpgradeLog*.htm 164 | 165 | # SQL Server files 166 | App_Data/*.mdf 167 | App_Data/*.ldf 168 | 169 | ############# 170 | ## Windows detritus 171 | ############# 172 | 173 | # Windows image file caches 174 | Thumbs.db 175 | ehthumbs.db 176 | 177 | # Folder config file 178 | Desktop.ini 179 | 180 | # Recycle Bin used on file shares 181 | $RECYCLE.BIN/ 182 | 183 | # Mac crap 184 | .DS_Store 185 | 186 | 187 | ############# 188 | ## Python 189 | ############# 190 | 191 | *.py[cod] 192 | 193 | # Packages 194 | *.egg 195 | *.egg-info 196 | dist/ 197 | build/ 198 | eggs/ 199 | parts/ 200 | var/ 201 | sdist/ 202 | develop-eggs/ 203 | .installed.cfg 204 | 205 | # Installer logs 206 | pip-log.txt 207 | 208 | # Unit test / coverage reports 209 | .coverage 210 | .tox 211 | 212 | #Translations 213 | *.mo 214 | 215 | #Mr Developer 216 | .mr.developer.cfg 217 | -------------------------------------------------------------------------------- /ChatBoxbyWebView/ChatBoxbyWebView.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.23107.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChatBoxbyWebView", "ChatBoxbyWebView\ChatBoxbyWebView.csproj", "{574B5934-85A3-47B7-9BB8-85BF8058EB03}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|ARM = Debug|ARM 11 | Debug|x64 = Debug|x64 12 | Debug|x86 = Debug|x86 13 | Release|ARM = Release|ARM 14 | Release|x64 = Release|x64 15 | Release|x86 = Release|x86 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {574B5934-85A3-47B7-9BB8-85BF8058EB03}.Debug|ARM.ActiveCfg = Debug|ARM 19 | {574B5934-85A3-47B7-9BB8-85BF8058EB03}.Debug|ARM.Build.0 = Debug|ARM 20 | {574B5934-85A3-47B7-9BB8-85BF8058EB03}.Debug|ARM.Deploy.0 = Debug|ARM 21 | {574B5934-85A3-47B7-9BB8-85BF8058EB03}.Debug|x64.ActiveCfg = Debug|x64 22 | {574B5934-85A3-47B7-9BB8-85BF8058EB03}.Debug|x64.Build.0 = Debug|x64 23 | {574B5934-85A3-47B7-9BB8-85BF8058EB03}.Debug|x64.Deploy.0 = Debug|x64 24 | {574B5934-85A3-47B7-9BB8-85BF8058EB03}.Debug|x86.ActiveCfg = Debug|x86 25 | {574B5934-85A3-47B7-9BB8-85BF8058EB03}.Debug|x86.Build.0 = Debug|x86 26 | {574B5934-85A3-47B7-9BB8-85BF8058EB03}.Debug|x86.Deploy.0 = Debug|x86 27 | {574B5934-85A3-47B7-9BB8-85BF8058EB03}.Release|ARM.ActiveCfg = Release|ARM 28 | {574B5934-85A3-47B7-9BB8-85BF8058EB03}.Release|ARM.Build.0 = Release|ARM 29 | {574B5934-85A3-47B7-9BB8-85BF8058EB03}.Release|ARM.Deploy.0 = Release|ARM 30 | {574B5934-85A3-47B7-9BB8-85BF8058EB03}.Release|x64.ActiveCfg = Release|x64 31 | {574B5934-85A3-47B7-9BB8-85BF8058EB03}.Release|x64.Build.0 = Release|x64 32 | {574B5934-85A3-47B7-9BB8-85BF8058EB03}.Release|x64.Deploy.0 = Release|x64 33 | {574B5934-85A3-47B7-9BB8-85BF8058EB03}.Release|x86.ActiveCfg = Release|x86 34 | {574B5934-85A3-47B7-9BB8-85BF8058EB03}.Release|x86.Build.0 = Release|x86 35 | {574B5934-85A3-47B7-9BB8-85BF8058EB03}.Release|x86.Deploy.0 = Release|x86 36 | EndGlobalSection 37 | GlobalSection(SolutionProperties) = preSolution 38 | HideSolutionNode = FALSE 39 | EndGlobalSection 40 | EndGlobal 41 | -------------------------------------------------------------------------------- /ChatBoxbyWebView/ChatBoxbyWebView/App.xaml: -------------------------------------------------------------------------------- 1 |  7 | 8 | 9 | -------------------------------------------------------------------------------- /ChatBoxbyWebView/ChatBoxbyWebView/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Runtime.InteropServices.WindowsRuntime; 6 | using Windows.ApplicationModel; 7 | using Windows.ApplicationModel.Activation; 8 | using Windows.Foundation; 9 | using Windows.Foundation.Collections; 10 | using Windows.UI.Xaml; 11 | using Windows.UI.Xaml.Controls; 12 | using Windows.UI.Xaml.Controls.Primitives; 13 | using Windows.UI.Xaml.Data; 14 | using Windows.UI.Xaml.Input; 15 | using Windows.UI.Xaml.Media; 16 | using Windows.UI.Xaml.Navigation; 17 | 18 | namespace ChatBoxbyWebView 19 | { 20 | /// 21 | /// 提供特定于应用程序的行为,以补充默认的应用程序类。 22 | /// 23 | sealed partial class App : Application 24 | { 25 | /// 26 | /// 初始化单一实例应用程序对象。这是执行的创作代码的第一行, 27 | /// 已执行,逻辑上等同于 main() 或 WinMain()。 28 | /// 29 | public App() 30 | { 31 | Microsoft.ApplicationInsights.WindowsAppInitializer.InitializeAsync( 32 | Microsoft.ApplicationInsights.WindowsCollectors.Metadata | 33 | Microsoft.ApplicationInsights.WindowsCollectors.Session); 34 | this.InitializeComponent(); 35 | this.Suspending += OnSuspending; 36 | } 37 | 38 | /// 39 | /// 在应用程序由最终用户正常启动时进行调用。 40 | /// 将在启动应用程序以打开特定文件等情况下使用。 41 | /// 42 | /// 有关启动请求和过程的详细信息。 43 | protected override void OnLaunched(LaunchActivatedEventArgs e) 44 | { 45 | Frame rootFrame = Window.Current.Content as Frame; 46 | 47 | // 不要在窗口已包含内容时重复应用程序初始化, 48 | // 只需确保窗口处于活动状态 49 | if (rootFrame == null) 50 | { 51 | // 创建要充当导航上下文的框架,并导航到第一页 52 | rootFrame = new Frame(); 53 | 54 | rootFrame.NavigationFailed += OnNavigationFailed; 55 | 56 | if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) 57 | { 58 | //TODO: 从之前挂起的应用程序加载状态 59 | } 60 | 61 | // 将框架放在当前窗口中 62 | Window.Current.Content = rootFrame; 63 | } 64 | 65 | if (rootFrame.Content == null) 66 | { 67 | // 当导航堆栈尚未还原时,导航到第一页, 68 | // 并通过将所需信息作为导航参数传入来配置 69 | // 参数 70 | rootFrame.Navigate(typeof(MainPage), e.Arguments); 71 | } 72 | // 确保当前窗口处于活动状态 73 | Window.Current.Activate(); 74 | } 75 | 76 | /// 77 | /// 导航到特定页失败时调用 78 | /// 79 | ///导航失败的框架 80 | ///有关导航失败的详细信息 81 | void OnNavigationFailed(object sender, NavigationFailedEventArgs e) 82 | { 83 | throw new Exception("Failed to load Page " + e.SourcePageType.FullName); 84 | } 85 | 86 | /// 87 | /// 在将要挂起应用程序执行时调用。 在不知道应用程序 88 | /// 无需知道应用程序会被终止还是会恢复, 89 | /// 并让内存内容保持不变。 90 | /// 91 | /// 挂起的请求的源。 92 | /// 有关挂起请求的详细信息。 93 | private void OnSuspending(object sender, SuspendingEventArgs e) 94 | { 95 | var deferral = e.SuspendingOperation.GetDeferral(); 96 | //TODO: 保存应用程序状态并停止任何后台活动 97 | deferral.Complete(); 98 | } 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /ChatBoxbyWebView/ChatBoxbyWebView/ApplicationInsights.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /ChatBoxbyWebView/ChatBoxbyWebView/Assets/LockScreenLogo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sherlockchou86/Blogs/cef7bd0ceba0bb59ff2d51b68f581b5c03128530/ChatBoxbyWebView/ChatBoxbyWebView/Assets/LockScreenLogo.scale-200.png -------------------------------------------------------------------------------- /ChatBoxbyWebView/ChatBoxbyWebView/Assets/SplashScreen.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sherlockchou86/Blogs/cef7bd0ceba0bb59ff2d51b68f581b5c03128530/ChatBoxbyWebView/ChatBoxbyWebView/Assets/SplashScreen.scale-200.png -------------------------------------------------------------------------------- /ChatBoxbyWebView/ChatBoxbyWebView/Assets/Square150x150Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sherlockchou86/Blogs/cef7bd0ceba0bb59ff2d51b68f581b5c03128530/ChatBoxbyWebView/ChatBoxbyWebView/Assets/Square150x150Logo.scale-200.png -------------------------------------------------------------------------------- /ChatBoxbyWebView/ChatBoxbyWebView/Assets/Square44x44Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sherlockchou86/Blogs/cef7bd0ceba0bb59ff2d51b68f581b5c03128530/ChatBoxbyWebView/ChatBoxbyWebView/Assets/Square44x44Logo.scale-200.png -------------------------------------------------------------------------------- /ChatBoxbyWebView/ChatBoxbyWebView/Assets/Square44x44Logo.targetsize-24_altform-unplated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sherlockchou86/Blogs/cef7bd0ceba0bb59ff2d51b68f581b5c03128530/ChatBoxbyWebView/ChatBoxbyWebView/Assets/Square44x44Logo.targetsize-24_altform-unplated.png -------------------------------------------------------------------------------- /ChatBoxbyWebView/ChatBoxbyWebView/Assets/StoreLogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sherlockchou86/Blogs/cef7bd0ceba0bb59ff2d51b68f581b5c03128530/ChatBoxbyWebView/ChatBoxbyWebView/Assets/StoreLogo.png -------------------------------------------------------------------------------- /ChatBoxbyWebView/ChatBoxbyWebView/Assets/Wide310x150Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sherlockchou86/Blogs/cef7bd0ceba0bb59ff2d51b68f581b5c03128530/ChatBoxbyWebView/ChatBoxbyWebView/Assets/Wide310x150Logo.scale-200.png -------------------------------------------------------------------------------- /ChatBoxbyWebView/ChatBoxbyWebView/ChatBoxTool.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Windows.UI.Xaml.Controls; 7 | 8 | namespace ChatBoxbyWebView 9 | { 10 | /// 11 | /// 聊天框工具 12 | /// 13 | class ChatBoxTool 14 | { 15 | static string _bastChatHtml = @" 16 | 17 | 140 | "; 141 | 142 | //接收消息html 143 | //点击昵称、头像时 js与C#代码进行通信 window.external.notify(...) 144 | static string _receiveHtml = @" 145 |
146 | 147 |

{1}

148 |

{2}

149 |
"; 150 | //发送消息html 151 | static string _sendHtml = @" 152 |
153 | 154 |

{1}

155 |

{2}

156 |
"; 157 | 158 | 159 | /// 160 | /// 当前聊天框 161 | /// 162 | private WebView _chat_box; 163 | /// 164 | /// 初始化 165 | /// 166 | /// 167 | public ChatBoxTool(WebView wv) 168 | { 169 | _chat_box = wv; 170 | _chat_box.NavigateToString(_bastChatHtml); 171 | } 172 | /// 173 | /// 聊天框接收消息 174 | /// 175 | /// 176 | /// 177 | /// 178 | /// 179 | /// 180 | public async void Receive(string avatar, string nickname, string content, string time) 181 | { 182 | //将消息转换成html 183 | string html_2_insert = String.Format(_receiveHtml, avatar, nickname + " " + time, content, nickname, nickname); 184 | 185 | //C# 与 js通信 186 | string js = ""; 187 | js += "var div = document.createElement('div');"; //创建div 188 | js += "div.innerHTML=\"" + html_2_insert.Replace("\"","\\\"").Replace("\r\n","") + "\";"; //插入html 189 | js += "document.body.appendChild(div);"; //将div添加到body中 190 | js += "location.href='#ok';"; //webview定位到最新一条消息 191 | js += "document.getElementById('ok').remove();"; //将锚点移除 192 | 193 | await _chat_box.InvokeScriptAsync("eval", new string[] { js }); //调用js 194 | } 195 | /// 196 | /// 聊天框发送消息 197 | /// 198 | /// 199 | /// 200 | /// 201 | /// 202 | /// 203 | public async void Send(string avatar, string nickname, string content, string time) 204 | { 205 | //将消息转换成html 206 | string html_2_insert = String.Format(_sendHtml, avatar, time + " " + nickname, content); 207 | 208 | //C# 与 js通信 209 | string js = ""; 210 | js += "var div = document.createElement('div');"; //创建div 211 | js += "div.innerHTML=\"" + html_2_insert.Replace("\"", "\\\"").Replace("\r\n", "") + "\";"; //插入html 212 | js += "document.body.appendChild(div);"; //将div添加到body中 213 | js += "location.href='#ok';"; //webview定位到最新一条消息 214 | js += "document.getElementById('ok').remove();"; //将锚点移除 215 | 216 | await _chat_box.InvokeScriptAsync("eval", new string[] { js }); //调用js 217 | } 218 | } 219 | } 220 | -------------------------------------------------------------------------------- /ChatBoxbyWebView/ChatBoxbyWebView/ChatBoxbyWebView.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | x86 7 | {574B5934-85A3-47B7-9BB8-85BF8058EB03} 8 | AppContainerExe 9 | Properties 10 | ChatBoxbyWebView 11 | ChatBoxbyWebView 12 | zh-CN 13 | UAP 14 | 10.0.10240.0 15 | 10.0.10240.0 16 | 14 17 | true 18 | 512 19 | {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 20 | ChatBoxbyWebView_TemporaryKey.pfx 21 | 22 | 23 | true 24 | bin\ARM\Debug\ 25 | DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP 26 | ;2008 27 | full 28 | ARM 29 | false 30 | prompt 31 | true 32 | 33 | 34 | bin\ARM\Release\ 35 | TRACE;NETFX_CORE;WINDOWS_UWP 36 | true 37 | ;2008 38 | pdbonly 39 | ARM 40 | false 41 | prompt 42 | true 43 | true 44 | 45 | 46 | true 47 | bin\x64\Debug\ 48 | DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP 49 | ;2008 50 | full 51 | x64 52 | false 53 | prompt 54 | true 55 | 56 | 57 | bin\x64\Release\ 58 | TRACE;NETFX_CORE;WINDOWS_UWP 59 | true 60 | ;2008 61 | pdbonly 62 | x64 63 | false 64 | prompt 65 | true 66 | true 67 | 68 | 69 | true 70 | bin\x86\Debug\ 71 | DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP 72 | ;2008 73 | full 74 | x86 75 | false 76 | prompt 77 | true 78 | 79 | 80 | bin\x86\Release\ 81 | TRACE;NETFX_CORE;WINDOWS_UWP 82 | true 83 | ;2008 84 | pdbonly 85 | x86 86 | false 87 | prompt 88 | true 89 | true 90 | 91 | 92 | 93 | 94 | PreserveNewest 95 | 96 | 97 | 98 | 99 | 100 | App.xaml 101 | 102 | 103 | 104 | MainPage.xaml 105 | 106 | 107 | 108 | 109 | 110 | Designer 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | MSBuild:Compile 127 | Designer 128 | 129 | 130 | MSBuild:Compile 131 | Designer 132 | 133 | 134 | 135 | 14.0 136 | 137 | 138 | 145 | -------------------------------------------------------------------------------- /ChatBoxbyWebView/ChatBoxbyWebView/MainPage.xaml: -------------------------------------------------------------------------------- 1 |  9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 36 | 41 | 46 | 47 | 48 | 49 | 52 | 53 | 54 | 60 | 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /ChatBoxbyWebView/ChatBoxbyWebView/MainPage.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Runtime.InteropServices.WindowsRuntime; 6 | using Windows.Foundation; 7 | using Windows.Foundation.Collections; 8 | using Windows.UI.Xaml; 9 | using Windows.UI.Xaml.Controls; 10 | using Windows.UI.Xaml.Controls.Primitives; 11 | using Windows.UI.Xaml.Data; 12 | using Windows.UI.Xaml.Input; 13 | using Windows.UI.Xaml.Media; 14 | using Windows.UI.Xaml.Navigation; 15 | 16 | //“空白页”项模板在 http://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409 上有介绍 17 | 18 | namespace ChatBoxbyWebView 19 | { 20 | /// 21 | /// 可用于自身或导航至 Frame 内部的空白页。 22 | /// 23 | public sealed partial class MainPage : Page 24 | { 25 | ChatBoxTool _chat_box_tool; 26 | public MainPage() 27 | { 28 | this.InitializeComponent(); 29 | _chat_box_tool = new ChatBoxTool(ChatBox); 30 | ChatBox.ScriptNotify += ChatBox_ScriptNotify; //js 与 C#通信 31 | } 32 | /// 33 | /// 模拟接收文本 34 | /// 35 | /// 36 | /// 37 | private void Button_Click(object sender, RoutedEventArgs e) 38 | { 39 | //模拟产生的消息数据 40 | string avatar = "http://pic.cnblogs.com/avatar/104032/20150821151916.png"; 41 | string nick_name = "周见智"; 42 | string content = "模拟接收的加粗文本

你好!完美世界!"; 43 | string time = DateTime.Now.ToString(); 44 | 45 | _chat_box_tool.Receive(avatar, nick_name, content, time); //插入聊天框 46 | } 47 | /// 48 | /// 模拟接收图片 49 | /// 50 | /// 51 | /// 52 | private void Button_Click_1(object sender, RoutedEventArgs e) 53 | { 54 | //模拟产生的消息数据 55 | string avatar = "http://pic.cnblogs.com/avatar/104032/20150821151916.png"; 56 | string nick_name = "周见智"; 57 | string content = "模拟接收的图片

"; 58 | string time = DateTime.Now.ToString(); 59 | 60 | _chat_box_tool.Receive(avatar, nick_name, content, time); //插入聊天框 61 | } 62 | /// 63 | /// 模拟接收视频 64 | /// 65 | /// 66 | /// 67 | private void Button_Click_2(object sender, RoutedEventArgs e) 68 | { 69 | //模拟产生的消息数据 70 | string avatar = "http://pic.cnblogs.com/avatar/104032/20150821151916.png"; 71 | string nick_name = "周见智"; 72 | string content = "模拟接收的视频
"; 73 | string time = DateTime.Now.ToString(); 74 | 75 | _chat_box_tool.Receive(avatar, nick_name, content, time); //插入聊天框 76 | } 77 | /// 78 | /// 模拟发送文本 79 | /// 80 | /// 81 | /// 82 | private void Button_Click_3(object sender, RoutedEventArgs e) 83 | { 84 | if (!Text2Send.Text.Equals("")) 85 | { 86 | string avatar = "http://pic.cnblogs.com/avatar/624159/20150505133758.png"; 87 | string nick_name = "周加祖"; 88 | string content = Text2Send.Text; 89 | string time = DateTime.Now.ToString(); 90 | 91 | _chat_box_tool.Send(avatar, nick_name, content, time); //插入聊天框 92 | } 93 | } 94 | 95 | /// 96 | /// 模拟发送超链接 97 | /// 98 | /// 99 | /// 100 | private void Button_Click_4(object sender, RoutedEventArgs e) 101 | { 102 | string avatar = "http://pic.cnblogs.com/avatar/624159/20150505133758.png"; 103 | string nick_name = "周加祖"; 104 | string content = "发送一条链接,关注我博客
www.cnblogs.com/xiaozhi_5638/"; 105 | string time = DateTime.Now.ToString(); 106 | _chat_box_tool.Send(avatar, nick_name, content, time); //插入聊天框 107 | } 108 | 109 | 110 | /// 111 | /// 鼠标点击webview中的昵称 js向C#传递’点击的昵称‘ 112 | /// 113 | /// 114 | /// 115 | private void ChatBox_ScriptNotify(object sender, NotifyEventArgs e) 116 | { 117 | //将昵称添加到输入框 118 | Text2Send.Text += "@" + e.Value + " "; //点击昵称 @该用户 119 | } 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /ChatBoxbyWebView/ChatBoxbyWebView/Package.appxmanifest: -------------------------------------------------------------------------------- 1 |  2 | 3 | 8 | 9 | 13 | 14 | 15 | 16 | 17 | ChatBoxbyWebView 18 | zhi 19 | Assets\StoreLogo.png 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 34 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /ChatBoxbyWebView/ChatBoxbyWebView/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("ChatBoxbyWebView")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("ChatBoxbyWebView")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Version information for an assembly consists of the following four values: 18 | // 19 | // Major Version 20 | // Minor Version 21 | // Build Number 22 | // Revision 23 | // 24 | // You can specify all the values or you can default the Build and Revision Numbers 25 | // by using the '*' as shown below: 26 | // [assembly: AssemblyVersion("1.0.*")] 27 | [assembly: AssemblyVersion("1.0.0.0")] 28 | [assembly: AssemblyFileVersion("1.0.0.0")] 29 | [assembly: ComVisible(false)] -------------------------------------------------------------------------------- /ChatBoxbyWebView/ChatBoxbyWebView/Properties/Default.rd.xml: -------------------------------------------------------------------------------- 1 | 17 | 18 | 19 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /ChatBoxbyWebView/ChatBoxbyWebView/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "Microsoft.ApplicationInsights": "1.0.0", 4 | "Microsoft.ApplicationInsights.PersistenceChannel": "1.0.0", 5 | "Microsoft.ApplicationInsights.WindowsApps": "1.0.0", 6 | "Microsoft.NETCore.UniversalWindowsPlatform": "5.0.0" 7 | }, 8 | "frameworks": { 9 | "uap10.0": {} 10 | }, 11 | "runtimes": { 12 | "win10-arm": {}, 13 | "win10-arm-aot": {}, 14 | "win10-x86": {}, 15 | "win10-x86-aot": {}, 16 | "win10-x64": {}, 17 | "win10-x64-aot": {} 18 | } 19 | } -------------------------------------------------------------------------------- /LoadingItemsInListView/LoadingItemsInListView.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.23107.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LoadingItemsInListView", "LoadingItemsInListView\LoadingItemsInListView.csproj", "{4EB2B75B-57D0-4013-9B32-F839D570E534}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|ARM = Debug|ARM 11 | Debug|x64 = Debug|x64 12 | Debug|x86 = Debug|x86 13 | Release|ARM = Release|ARM 14 | Release|x64 = Release|x64 15 | Release|x86 = Release|x86 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {4EB2B75B-57D0-4013-9B32-F839D570E534}.Debug|ARM.ActiveCfg = Debug|ARM 19 | {4EB2B75B-57D0-4013-9B32-F839D570E534}.Debug|ARM.Build.0 = Debug|ARM 20 | {4EB2B75B-57D0-4013-9B32-F839D570E534}.Debug|ARM.Deploy.0 = Debug|ARM 21 | {4EB2B75B-57D0-4013-9B32-F839D570E534}.Debug|x64.ActiveCfg = Debug|x64 22 | {4EB2B75B-57D0-4013-9B32-F839D570E534}.Debug|x64.Build.0 = Debug|x64 23 | {4EB2B75B-57D0-4013-9B32-F839D570E534}.Debug|x64.Deploy.0 = Debug|x64 24 | {4EB2B75B-57D0-4013-9B32-F839D570E534}.Debug|x86.ActiveCfg = Debug|x86 25 | {4EB2B75B-57D0-4013-9B32-F839D570E534}.Debug|x86.Build.0 = Debug|x86 26 | {4EB2B75B-57D0-4013-9B32-F839D570E534}.Debug|x86.Deploy.0 = Debug|x86 27 | {4EB2B75B-57D0-4013-9B32-F839D570E534}.Release|ARM.ActiveCfg = Release|ARM 28 | {4EB2B75B-57D0-4013-9B32-F839D570E534}.Release|ARM.Build.0 = Release|ARM 29 | {4EB2B75B-57D0-4013-9B32-F839D570E534}.Release|ARM.Deploy.0 = Release|ARM 30 | {4EB2B75B-57D0-4013-9B32-F839D570E534}.Release|x64.ActiveCfg = Release|x64 31 | {4EB2B75B-57D0-4013-9B32-F839D570E534}.Release|x64.Build.0 = Release|x64 32 | {4EB2B75B-57D0-4013-9B32-F839D570E534}.Release|x64.Deploy.0 = Release|x64 33 | {4EB2B75B-57D0-4013-9B32-F839D570E534}.Release|x86.ActiveCfg = Release|x86 34 | {4EB2B75B-57D0-4013-9B32-F839D570E534}.Release|x86.Build.0 = Release|x86 35 | {4EB2B75B-57D0-4013-9B32-F839D570E534}.Release|x86.Deploy.0 = Release|x86 36 | EndGlobalSection 37 | GlobalSection(SolutionProperties) = preSolution 38 | HideSolutionNode = FALSE 39 | EndGlobalSection 40 | EndGlobal 41 | -------------------------------------------------------------------------------- /LoadingItemsInListView/LoadingItemsInListView/App.xaml: -------------------------------------------------------------------------------- 1 |  7 | 8 | 9 | -------------------------------------------------------------------------------- /LoadingItemsInListView/LoadingItemsInListView/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Runtime.InteropServices.WindowsRuntime; 6 | using Windows.ApplicationModel; 7 | using Windows.ApplicationModel.Activation; 8 | using Windows.Foundation; 9 | using Windows.Foundation.Collections; 10 | using Windows.UI.Xaml; 11 | using Windows.UI.Xaml.Controls; 12 | using Windows.UI.Xaml.Controls.Primitives; 13 | using Windows.UI.Xaml.Data; 14 | using Windows.UI.Xaml.Input; 15 | using Windows.UI.Xaml.Media; 16 | using Windows.UI.Xaml.Navigation; 17 | 18 | namespace LoadingItemsInListView 19 | { 20 | /// 21 | /// 提供特定于应用程序的行为,以补充默认的应用程序类。 22 | /// 23 | sealed partial class App : Application 24 | { 25 | /// 26 | /// 初始化单一实例应用程序对象。这是执行的创作代码的第一行, 27 | /// 已执行,逻辑上等同于 main() 或 WinMain()。 28 | /// 29 | public App() 30 | { 31 | Microsoft.ApplicationInsights.WindowsAppInitializer.InitializeAsync( 32 | Microsoft.ApplicationInsights.WindowsCollectors.Metadata | 33 | Microsoft.ApplicationInsights.WindowsCollectors.Session); 34 | this.InitializeComponent(); 35 | this.Suspending += OnSuspending; 36 | } 37 | 38 | /// 39 | /// 在应用程序由最终用户正常启动时进行调用。 40 | /// 将在启动应用程序以打开特定文件等情况下使用。 41 | /// 42 | /// 有关启动请求和过程的详细信息。 43 | protected override void OnLaunched(LaunchActivatedEventArgs e) 44 | { 45 | Frame rootFrame = Window.Current.Content as Frame; 46 | 47 | // 不要在窗口已包含内容时重复应用程序初始化, 48 | // 只需确保窗口处于活动状态 49 | if (rootFrame == null) 50 | { 51 | // 创建要充当导航上下文的框架,并导航到第一页 52 | rootFrame = new Frame(); 53 | 54 | rootFrame.NavigationFailed += OnNavigationFailed; 55 | 56 | if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) 57 | { 58 | //TODO: 从之前挂起的应用程序加载状态 59 | } 60 | 61 | // 将框架放在当前窗口中 62 | Window.Current.Content = rootFrame; 63 | } 64 | 65 | if (rootFrame.Content == null) 66 | { 67 | // 当导航堆栈尚未还原时,导航到第一页, 68 | // 并通过将所需信息作为导航参数传入来配置 69 | // 参数 70 | rootFrame.Navigate(typeof(MainPage), e.Arguments); 71 | } 72 | // 确保当前窗口处于活动状态 73 | Window.Current.Activate(); 74 | } 75 | 76 | /// 77 | /// 导航到特定页失败时调用 78 | /// 79 | ///导航失败的框架 80 | ///有关导航失败的详细信息 81 | void OnNavigationFailed(object sender, NavigationFailedEventArgs e) 82 | { 83 | throw new Exception("Failed to load Page " + e.SourcePageType.FullName); 84 | } 85 | 86 | /// 87 | /// 在将要挂起应用程序执行时调用。 在不知道应用程序 88 | /// 无需知道应用程序会被终止还是会恢复, 89 | /// 并让内存内容保持不变。 90 | /// 91 | /// 挂起的请求的源。 92 | /// 有关挂起请求的详细信息。 93 | private void OnSuspending(object sender, SuspendingEventArgs e) 94 | { 95 | var deferral = e.SuspendingOperation.GetDeferral(); 96 | //TODO: 保存应用程序状态并停止任何后台活动 97 | deferral.Complete(); 98 | } 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /LoadingItemsInListView/LoadingItemsInListView/ApplicationInsights.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /LoadingItemsInListView/LoadingItemsInListView/Assets/LockScreenLogo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sherlockchou86/Blogs/cef7bd0ceba0bb59ff2d51b68f581b5c03128530/LoadingItemsInListView/LoadingItemsInListView/Assets/LockScreenLogo.scale-200.png -------------------------------------------------------------------------------- /LoadingItemsInListView/LoadingItemsInListView/Assets/SplashScreen.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sherlockchou86/Blogs/cef7bd0ceba0bb59ff2d51b68f581b5c03128530/LoadingItemsInListView/LoadingItemsInListView/Assets/SplashScreen.scale-200.png -------------------------------------------------------------------------------- /LoadingItemsInListView/LoadingItemsInListView/Assets/Square150x150Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sherlockchou86/Blogs/cef7bd0ceba0bb59ff2d51b68f581b5c03128530/LoadingItemsInListView/LoadingItemsInListView/Assets/Square150x150Logo.scale-200.png -------------------------------------------------------------------------------- /LoadingItemsInListView/LoadingItemsInListView/Assets/Square44x44Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sherlockchou86/Blogs/cef7bd0ceba0bb59ff2d51b68f581b5c03128530/LoadingItemsInListView/LoadingItemsInListView/Assets/Square44x44Logo.scale-200.png -------------------------------------------------------------------------------- /LoadingItemsInListView/LoadingItemsInListView/Assets/Square44x44Logo.targetsize-24_altform-unplated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sherlockchou86/Blogs/cef7bd0ceba0bb59ff2d51b68f581b5c03128530/LoadingItemsInListView/LoadingItemsInListView/Assets/Square44x44Logo.targetsize-24_altform-unplated.png -------------------------------------------------------------------------------- /LoadingItemsInListView/LoadingItemsInListView/Assets/StoreLogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sherlockchou86/Blogs/cef7bd0ceba0bb59ff2d51b68f581b5c03128530/LoadingItemsInListView/LoadingItemsInListView/Assets/StoreLogo.png -------------------------------------------------------------------------------- /LoadingItemsInListView/LoadingItemsInListView/Assets/Wide310x150Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sherlockchou86/Blogs/cef7bd0ceba0bb59ff2d51b68f581b5c03128530/LoadingItemsInListView/LoadingItemsInListView/Assets/Wide310x150Logo.scale-200.png -------------------------------------------------------------------------------- /LoadingItemsInListView/LoadingItemsInListView/BaseService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using System.IO; 5 | using System.Linq; 6 | using System.Net; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using Windows.Web.Http; 10 | 11 | namespace LoadingItemsInListView 12 | { 13 | /// 14 | /// 访问HTTP服务器基础服务 15 | /// 16 | static class BaseService 17 | { 18 | /// 19 | /// 访问服务器时的cookies 20 | /// 21 | public static CookieContainer CookiesContainer; 22 | /// 23 | /// 向服务器发送get请求 返回服务器回复数据 24 | /// 25 | /// 26 | /// 27 | public async static Task SendGetRequest(string url) 28 | { 29 | try 30 | { 31 | HttpClient client = new HttpClient(); 32 | Uri uri = new Uri(url); 33 | 34 | HttpResponseMessage response = await client.GetAsync(uri); 35 | response.EnsureSuccessStatusCode(); 36 | 37 | return await response.Content.ReadAsStringAsync(); 38 | } 39 | catch 40 | { 41 | return null; 42 | } 43 | 44 | } 45 | /// 46 | /// 向服务器发送post请求 返回服务器回复数据 47 | /// 48 | /// 49 | /// 50 | /// 51 | public async static Task SendPostRequest(string url, string body) 52 | { 53 | try 54 | { 55 | HttpRequestMessage mSent = new HttpRequestMessage(HttpMethod.Post, new Uri(url)); 56 | mSent.Content = new HttpStringContent(body, Windows.Storage.Streams.UnicodeEncoding.Utf8, "application/json; charset=utf-8"); 57 | HttpClient client = new HttpClient(); 58 | HttpResponseMessage response = await client.SendRequestAsync(mSent); 59 | response.EnsureSuccessStatusCode(); 60 | 61 | return await response.Content.ReadAsStringAsync(); 62 | } 63 | catch 64 | { 65 | return null; 66 | } 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /LoadingItemsInListView/LoadingItemsInListView/BlogService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Xml; 7 | 8 | namespace LoadingItemsInListView 9 | { 10 | static class BlogService 11 | { 12 | static string _url_recent_blog = "http://wcf.open.cnblogs.com/blog/sitehome/paged/{0}/{1}"; //page_index page_size 13 | /// 14 | /// 分页获取首页博客 15 | /// 16 | /// 17 | /// 18 | /// 19 | public async static Task> GetRecentBlogsAsync(int page_index, int page_size) 20 | { 21 | try 22 | { 23 | string url = string.Format(_url_recent_blog, page_index, page_size); 24 | string xml = await BaseService.SendGetRequest(url); 25 | if (xml != null) 26 | { 27 | List list_blogs = new List(); 28 | CNBlog cnblog; 29 | XmlDocument doc = new XmlDocument(); 30 | doc.LoadXml(xml); 31 | XmlNode feed = doc.ChildNodes[1]; 32 | foreach (XmlNode node in feed.ChildNodes) 33 | { 34 | if (node.Name.Equals("entry")) 35 | { 36 | cnblog = new CNBlog(); 37 | foreach (XmlNode node2 in node.ChildNodes) 38 | { 39 | if (node2.Name.Equals("id")) 40 | { 41 | cnblog.ID = node2.InnerText; 42 | } 43 | if (node2.Name.Equals("title")) 44 | { 45 | cnblog.Title = node2.InnerText; 46 | } 47 | if (node2.Name.Equals("summary")) 48 | { 49 | cnblog.Summary = node2.InnerText + "..."; 50 | } 51 | if (node2.Name.Equals("published")) 52 | { 53 | DateTime t = DateTime.Parse(node2.InnerText); 54 | cnblog.PublishTime = "发表于 " + t.ToString(); 55 | } 56 | if (node2.Name.Equals("updated")) 57 | { 58 | cnblog.UpdateTime = node2.InnerText; 59 | } 60 | if (node2.Name.Equals("author")) 61 | { 62 | cnblog.AuthorName = node2.ChildNodes[0].InnerText; 63 | cnblog.AuthorHome = node2.ChildNodes[1].InnerText; 64 | cnblog.AuthorAvator = node2.ChildNodes[2].InnerText.Equals("") ? "http://pic.cnblogs.com/avatar/simple_avatar.gif" : node2.ChildNodes[2].InnerText; 65 | } 66 | if (node2.Name.Equals("link")) 67 | { 68 | cnblog.BlogRawUrl = node2.Attributes["href"].Value; 69 | } 70 | if (node2.Name.Equals("blogapp")) 71 | { 72 | cnblog.BlogApp = node2.InnerText; 73 | } 74 | if (node2.Name.Equals("diggs")) 75 | { 76 | cnblog.Diggs = node2.InnerText; 77 | } 78 | if (node2.Name.Equals("views")) 79 | { 80 | cnblog.Views = "[" + node2.InnerText + "]"; 81 | } 82 | if (node2.Name.Equals("comments")) 83 | { 84 | cnblog.Comments = "[" + node2.InnerText + "]"; 85 | } 86 | } 87 | list_blogs.Add(cnblog); 88 | } 89 | } 90 | return list_blogs; 91 | } 92 | else 93 | { 94 | return null; 95 | } 96 | } 97 | catch 98 | { 99 | return null; 100 | } 101 | } 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /LoadingItemsInListView/LoadingItemsInListView/CNBlog.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace LoadingItemsInListView 8 | { 9 | /// 10 | /// 博客 11 | /// 12 | public class CNBlog 13 | { 14 | public int Index 15 | { 16 | get; set; 17 | } 18 | public string ID 19 | { 20 | get; set; 21 | } 22 | public string Title 23 | { 24 | get; set; 25 | } 26 | public string Summary 27 | { 28 | get; set; 29 | } 30 | public string PublishTime 31 | { 32 | get; set; 33 | } 34 | public string UpdateTime 35 | { 36 | get; set; 37 | } 38 | public string AuthorName 39 | { 40 | get; set; 41 | } 42 | public string AuthorAvator 43 | { 44 | get; set; 45 | } 46 | public string AuthorHome 47 | { 48 | get; set; 49 | } 50 | public string BlogRawUrl 51 | { 52 | get; set; 53 | } 54 | public string BlogApp 55 | { 56 | get; set; 57 | } 58 | public string Diggs 59 | { 60 | get; set; 61 | } 62 | public string Views 63 | { 64 | get; set; 65 | } 66 | public string Comments 67 | { 68 | get; set; 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /LoadingItemsInListView/LoadingItemsInListView/CNBlogItem.xaml: -------------------------------------------------------------------------------- 1 |  11 | 12 | 13 | 14 | 15 | 16 | 17 | 20 | 21 | 22 | 27 | 28 | 32 | 33 | 34 | 35 | 37 | 38 | 39 | 40 | 41 | 42 | 47 | 48 | 50 | 56 | 57 | 65 | 66 | 67 | 69 | 75 | 76 | 81 | 82 | 87 | 88 | 89 | 90 | 91 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | -------------------------------------------------------------------------------- /LoadingItemsInListView/LoadingItemsInListView/CNBlogItem.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Runtime.InteropServices.WindowsRuntime; 6 | using Windows.Foundation; 7 | using Windows.Foundation.Collections; 8 | using Windows.UI.Xaml; 9 | using Windows.UI.Xaml.Controls; 10 | using Windows.UI.Xaml.Controls.Primitives; 11 | using Windows.UI.Xaml.Data; 12 | using Windows.UI.Xaml.Input; 13 | using Windows.UI.Xaml.Media; 14 | using Windows.UI.Xaml.Media.Imaging; 15 | using Windows.UI.Xaml.Navigation; 16 | 17 | // The User Control item template is documented at http://go.microsoft.com/fwlink/?LinkId=234236 18 | 19 | namespace LoadingItemsInListView 20 | { 21 | public sealed partial class CNBlogItem : UserControl 22 | { 23 | public CNBlogItem(CNBlog blog) 24 | { 25 | this.InitializeComponent(); 26 | this.DataContext = blog; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /LoadingItemsInListView/LoadingItemsInListView/CNBlogList.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Collections.ObjectModel; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using Windows.Foundation; 8 | using Windows.UI.Xaml.Controls; 9 | using Windows.UI.Xaml.Data; 10 | 11 | namespace LoadingItemsInListView 12 | { 13 | class CNBlogList : ObservableCollection, ISupportIncrementalLoading 14 | { 15 | private bool _busy = false; 16 | private bool _has_more_items = false; 17 | private int _current_page = 1; 18 | public int TotalCount 19 | { 20 | get; set; 21 | } 22 | public bool HasMoreItems 23 | { 24 | get 25 | { 26 | if (_busy) 27 | return false; 28 | else 29 | return _has_more_items; 30 | } 31 | private set 32 | { 33 | _has_more_items = value; 34 | } 35 | } 36 | public CNBlogList() 37 | { 38 | HasMoreItems = true; 39 | } 40 | public void DoRefresh() 41 | { 42 | _current_page = 1; 43 | TotalCount = 0; 44 | Clear(); 45 | HasMoreItems = true; 46 | } 47 | public IAsyncOperation LoadMoreItemsAsync(uint count) 48 | { 49 | return InnerLoadMoreItemsAsync(count).AsAsyncOperation(); 50 | } 51 | private async Task InnerLoadMoreItemsAsync(uint expectedCount) 52 | { 53 | _busy = true; 54 | var actualCount = 0; 55 | List list = null; 56 | try 57 | { 58 | list = await BlogService.GetRecentBlogsAsync(_current_page, 20); 59 | } 60 | catch (Exception) 61 | { 62 | HasMoreItems = false; 63 | } 64 | 65 | if (list != null && list.Any()) 66 | { 67 | actualCount = list.Count; 68 | TotalCount += actualCount; 69 | _current_page++; 70 | HasMoreItems = true; 71 | list.ForEach((c) => { this.Add(c); }); 72 | } 73 | else 74 | { 75 | HasMoreItems = false; 76 | } 77 | _busy = false; 78 | return new LoadMoreItemsResult 79 | { 80 | Count = (uint)actualCount 81 | }; 82 | } 83 | } 84 | } -------------------------------------------------------------------------------- /LoadingItemsInListView/LoadingItemsInListView/LoadingItemsInListView.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | x86 7 | {4EB2B75B-57D0-4013-9B32-F839D570E534} 8 | AppContainerExe 9 | Properties 10 | LoadingItemsInListView 11 | LoadingItemsInListView 12 | zh-CN 13 | UAP 14 | 10.0.10240.0 15 | 10.0.10240.0 16 | 14 17 | true 18 | 512 19 | {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 20 | LoadingItemsInListView_TemporaryKey.pfx 21 | 22 | 23 | true 24 | bin\ARM\Debug\ 25 | DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP 26 | ;2008 27 | full 28 | ARM 29 | false 30 | prompt 31 | true 32 | 33 | 34 | bin\ARM\Release\ 35 | TRACE;NETFX_CORE;WINDOWS_UWP 36 | true 37 | ;2008 38 | pdbonly 39 | ARM 40 | false 41 | prompt 42 | true 43 | true 44 | 45 | 46 | true 47 | bin\x64\Debug\ 48 | DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP 49 | ;2008 50 | full 51 | x64 52 | false 53 | prompt 54 | true 55 | 56 | 57 | bin\x64\Release\ 58 | TRACE;NETFX_CORE;WINDOWS_UWP 59 | true 60 | ;2008 61 | pdbonly 62 | x64 63 | false 64 | prompt 65 | true 66 | true 67 | 68 | 69 | true 70 | bin\x86\Debug\ 71 | DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP 72 | ;2008 73 | full 74 | x86 75 | false 76 | prompt 77 | true 78 | 79 | 80 | bin\x86\Release\ 81 | TRACE;NETFX_CORE;WINDOWS_UWP 82 | true 83 | ;2008 84 | pdbonly 85 | x86 86 | false 87 | prompt 88 | true 89 | true 90 | 91 | 92 | 93 | 94 | PreserveNewest 95 | 96 | 97 | 98 | 99 | 100 | App.xaml 101 | 102 | 103 | 104 | 105 | CNBlogItem.xaml 106 | 107 | 108 | 109 | 110 | MainPage.xaml 111 | 112 | 113 | 114 | 115 | 116 | Designer 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | MSBuild:Compile 133 | Designer 134 | 135 | 136 | Designer 137 | MSBuild:Compile 138 | 139 | 140 | MSBuild:Compile 141 | Designer 142 | 143 | 144 | 145 | 14.0 146 | 147 | 148 | 155 | -------------------------------------------------------------------------------- /LoadingItemsInListView/LoadingItemsInListView/MainPage.xaml: -------------------------------------------------------------------------------- 1 |  10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 36 | 37 | 38 | 42 | 43 | 47 | 48 | 49 | 50 | 52 | 53 | 54 | 55 | 56 | 57 | 62 | 63 | 65 | 71 | 72 | 79 | 80 | 81 | 83 | 89 | 90 | 94 | 95 | 99 | 100 | 101 | 102 | 103 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 121 | 122 | 123 | 124 | 130 | 131 | 132 | 138 | 139 | 140 | 141 | 142 | -------------------------------------------------------------------------------- /LoadingItemsInListView/LoadingItemsInListView/MainPage.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Runtime.InteropServices.WindowsRuntime; 6 | using Windows.Foundation; 7 | using Windows.Foundation.Collections; 8 | using Windows.UI.Xaml; 9 | using Windows.UI.Xaml.Controls; 10 | using Windows.UI.Xaml.Controls.Primitives; 11 | using Windows.UI.Xaml.Data; 12 | using Windows.UI.Xaml.Input; 13 | using Windows.UI.Xaml.Media; 14 | using Windows.UI.Xaml.Navigation; 15 | 16 | //“空白页”项模板在 http://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409 上有介绍 17 | 18 | namespace LoadingItemsInListView 19 | { 20 | /// 21 | /// 可用于自身或导航至 Frame 内部的空白页。 22 | /// 23 | public sealed partial class MainPage : Page 24 | { 25 | CNBlogList _binding_list_blogs; 26 | 27 | int _unbinding_current_page = 1; 28 | bool _unbinding_busy = false; 29 | public MainPage() 30 | { 31 | this.InitializeComponent(); 32 | 33 | //BindingListView绑定到数据源 数据源自动加载数据 34 | BindingListView.ItemsSource = _binding_list_blogs = new CNBlogList(); 35 | 36 | //手动向UnBindingListView中添加一个与要显示的数据不同的项 37 | ListViewItem different_item = new ListViewItem(); 38 | different_item.Content = "我是单独不同的一项"; 39 | different_item.HorizontalContentAlignment = HorizontalAlignment.Center; 40 | UnBindingListView.Items.Add(different_item); 41 | 42 | //手动向UnBindingListView中添加一个按钮项 点击手动加载数据 43 | ListViewItem loading_more = new ListViewItem(); 44 | loading_more.Content = "点击加载更多..."; 45 | loading_more.HorizontalContentAlignment = HorizontalAlignment.Center; 46 | loading_more.Tapped += loading_more_Tapped; 47 | UnBindingListView.Items.Add(loading_more); 48 | } 49 | 50 | /// 51 | /// 点击加载更多 52 | /// 53 | /// 54 | /// 55 | private async void loading_more_Tapped(object sender, TappedRoutedEventArgs e) 56 | { 57 | if (_unbinding_busy) 58 | return; 59 | _unbinding_busy = true; 60 | (sender as ListViewItem).Content = "正在加载..."; 61 | 62 | List loading_item = await BlogService.GetRecentBlogsAsync(_unbinding_current_page, 20); 63 | if (loading_item != null) 64 | { 65 | loading_item.ForEach((blog) => 66 | { 67 | CNBlogItem item = new CNBlogItem(blog); 68 | UnBindingListView.Items.Insert(UnBindingListView.Items.Count - 1, item); 69 | }); 70 | _unbinding_current_page++; 71 | UnBindingListView.ScrollIntoView(sender); 72 | } 73 | (sender as ListViewItem).Content = "点击加载更多..."; 74 | _unbinding_busy = false; 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /LoadingItemsInListView/LoadingItemsInListView/Package.appxmanifest: -------------------------------------------------------------------------------- 1 |  2 | 3 | 8 | 9 | 13 | 14 | 15 | 16 | 17 | LoadingItemsInListView 18 | zhi 19 | Assets\StoreLogo.png 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 34 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /LoadingItemsInListView/LoadingItemsInListView/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("LoadingItemsInListView")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("LoadingItemsInListView")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Version information for an assembly consists of the following four values: 18 | // 19 | // Major Version 20 | // Minor Version 21 | // Build Number 22 | // Revision 23 | // 24 | // You can specify all the values or you can default the Build and Revision Numbers 25 | // by using the '*' as shown below: 26 | // [assembly: AssemblyVersion("1.0.*")] 27 | [assembly: AssemblyVersion("1.0.0.0")] 28 | [assembly: AssemblyFileVersion("1.0.0.0")] 29 | [assembly: ComVisible(false)] -------------------------------------------------------------------------------- /LoadingItemsInListView/LoadingItemsInListView/Properties/Default.rd.xml: -------------------------------------------------------------------------------- 1 | 17 | 18 | 19 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /LoadingItemsInListView/LoadingItemsInListView/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "Microsoft.ApplicationInsights": "1.0.0", 4 | "Microsoft.ApplicationInsights.PersistenceChannel": "1.0.0", 5 | "Microsoft.ApplicationInsights.WindowsApps": "1.0.0", 6 | "Microsoft.NETCore.UniversalWindowsPlatform": "5.0.0" 7 | }, 8 | "frameworks": { 9 | "uap10.0": {} 10 | }, 11 | "runtimes": { 12 | "win10-arm": {}, 13 | "win10-arm-aot": {}, 14 | "win10-x86": {}, 15 | "win10-x86-aot": {}, 16 | "win10-x64": {}, 17 | "win10-x64-aot": {} 18 | } 19 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ###这里存放博客源码### 2 | Source Code from my blog. 3 | 4 | --------------------- 5 | 6 | 7 | 博客请访问[博客地址](http://www.cnblogs.com/xiaozhi_5638/) 8 | 9 | See more [CNBlogs](http://www.cnblogs.com/xiaozhi_5638/) 10 | 11 | --------------------------------------------------------------------------------