This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 轉換時間 | |
function isoDate($timestamp = null) { | |
$tz = @date_default_timezone_get(); | |
@date_default_timezone_set('UTC'); | |
if (is_null($timestamp)) { | |
$timestamp = time(); | |
} | |
$returnValue = str_replace('+00:00', '.0000000Z', @date('c', $timestamp)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require_once 'vendor/autoload.php'; | |
use WindowsAzure\Common\ServicesBuilder; | |
use WindowsAzure\Blob\Models\CreateContainerOptions; | |
use WindowsAzure\Blob\Models\CreateBlobOptions; | |
use WindowsAzure\Blob\Models\PublicAccessType; | |
use WindowsAzure\Common\ServiceException; | |
$storageAccount = "填入你的 Windows Azure 儲存體名稱"; | |
$storagePrimaryKey = "填入對應的管理金鑰"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
using System.Collections.ObjectModel; | |
... | |
// 建立容器,裝訊息資料 | |
ObservableCollection<MessageModel> myList = new ObservableCollection<MessageModel>(); | |
// 將容器連結至 <ListView /> | |
MyListView.ItemsSource = myList; | |
// 把資料裝入容器內,<ListView /> 控制項也會逐一顯示 | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
public class MessageModel : System.ComponentModel.INotifyPropertyChanged | |
{ | |
private string _id; | |
public string Id | |
{ | |
get { return _id; } | |
set | |
{ | |
if (value != _id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
private void OnButtonClicked(object sender, RoutedEventArgs e) | |
{ | |
// 拿出 ListView 中的 ItemsSource | |
List<MessageModel> items = (List<MessageModel>)MyListView.ItemsSource; | |
// 修改其中一筆資料的內容 | |
items[0].Name = "Dan"; | |
} | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}"> | |
<StackPanel> | |
<Button x:Name="Change" Content="Change" Click="OnButtonClicked" /> | |
<ListView x:Name="MyListView" SelectionChanged="OnSelectionChanged"> | |
... | |
</ListView> | |
</StackPanel> | |
</Grid> | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
private void OnSelectionChanged(object sender, SelectionChangedEventArgs e) | |
{ | |
ListView source = (ListView)sender; | |
// 如果要將選取的 focus 移開,改變 SelectedIndex 就可以 | |
// 但就要處理被移開後不再重新呼叫 OnSelectionChanged | |
if (source.SelectedIndex != -1) | |
{ | |
// 取得選取的資料項目 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ListView x:Name="MyListView" | |
SelectionChanged="OnSelectionChanged"> | |
... | |
</ListView> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
// 建立容器,裝訊息資料 | |
List<MessageModel> myList = new List<MessageModel>(); | |
// 將容器連結至 <ListView /> | |
MyListView.ItemsSource = myList; | |
// 把資料裝入容器內,<ListView /> 控制項也會逐一顯示 | |
myList.Add(new MessageModel() | |
{ | |
Name = "Alice", | |
Message = "他上年紀的臉上一定滿佈著笑容你的小腳踝上不曾碰著過無情的荊刺,多謝你媽與你大大的慈愛與真摯,拘束永遠跟著我們,你得有力量翻起那岩石才能把它不傷損的連根起出誰知道那根長的多深!", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ListView x:Name="MyListView"> | |
<ListView.ItemTemplate> | |
<DataTemplate> | |
<StackPanel Orientation="Horizontal"> | |
<Image Width="75" Height="75" Source="{Binding AvatarUrl}" /> | |
<StackPanel Orientation="Vertical" Margin="5,0"> | |
<TextBlock Text="{Binding Name}" FontSize="24" FontWeight="Bold"/> | |
<TextBlock Text="{Binding Message}" TextWrapping="Wrap" /> | |
<TextBlock Text="{Binding PostTime}" Foreground="Gray"/> | |
</StackPanel> |