source.Add("Phaya Thai");
But I don't know how I create list form MySQL
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
mc:Ignorable="d"
shell:SystemTray.IsVisible="True">
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Net;
using System.IO;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
namespace Train_Guide_Thailand
{
public partial class SearchPage : PhoneApplicationPage
{
public SearchPage()
{
InitializeComponent();
//--SourceStation--
List
source.Add("Phaya Thai");
source.Add("Ladkrabang");
source.Add("Pra Chom Klao");
source.Add("aaaa");
source.Add("bbbb");
SourceStation.ItemsSource = source; // destinations;
//--destinationsStation--
List
destinations.Add("Phaya Thai");
destinations.Add("Ladkrabang");
destinations.Add("Pra Chom Klao");
destinations.Add("aaaa");
destinations.Add("bbbb");
DestStation.ItemsSource = destinations;
//--SourceStation
SourceStation.DropDownOpening += new RoutedPropertyChangingEventHandler
SourceStation.GotFocus += new RoutedEventHandler(SourceStation_GotFocus);
SourceStation.LostFocus += new RoutedEventHandler(SourceStation_LostFocus);
SourceStation.TextFilter += SearchStation;
SourceStation.TextChanged += new RoutedEventHandler(SourceStation_TextChanged);
SourceStation.SelectionChanged += new SelectionChangedEventHandler(SourceStation_SelectionChanged);
SourceStation.Text = "";
//--DestStation
SourceStation.DropDownOpening += new RoutedPropertyChangingEventHandler
SourceStation.GotFocus += new RoutedEventHandler(SourceStation_GotFocus);
SourceStation.LostFocus += new RoutedEventHandler(SourceStation_LostFocus);
SourceStation.TextFilter += SearchStation;
SourceStation.TextChanged += new RoutedEventHandler(SourceStation_TextChanged);
SourceStation.SelectionChanged += new SelectionChangedEventHandler(SourceStation_SelectionChanged);
SourceStation.Text = "";
}
bool SearchStation(string search, string value) // value is the possible match
{
if (!string.IsNullOrEmpty(search))
{
string currentText = search;
string filterText = currentText;
if (currentText.Contains(','))
{
int pos = currentText.LastIndexOf(',');
// get only what we have after comma
filterText = currentText.Substring(pos + 1);
}
// Look for a match in the last letter.
// do not allow to add twice the same tag from suggestion
if (value.ToLower().StartsWith(filterText) && !previouslyTypedCities.Contains(value))
{
return true; //match
}
}
// If no match
return false;
}
string previouslyTypedCities = "";
void SourceStation_TextChanged(object sender, RoutedEventArgs e)
{
try
{
if (SourceStation.Text.Contains(','))
{
int pos = SourceStation.Text.LastIndexOf(',');
if (pos > 0) previouslyTypedCities = SourceStation.Text.Substring(0, pos + 1); // get the comma as well
}
}
catch (Exception ex)
{
}
}
void SourceStation_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
try
{
if (e.RemovedItems.Count > 0) return;
if (e.AddedItems.Count > 0)
{
if (!previouslyTypedCities.Contains(SourceStation.Text))
{
// add the new selection
SourceStation.Text = previouslyTypedCities + SourceStation.Text;
// set new value
SourceStation.SelectedItem = SourceStation.Text;
}
}
}
catch (Exception ex)
{
}
}
private bool SourceStationFocused = false;
void SourceStation_LostFocus(object sender, RoutedEventArgs e)
{
SourceStationFocused = false;
}
void SourceStation_GotFocus(object sender, RoutedEventArgs e)
{
SourceStationFocused = true;
}
void SourceStation_DropDownOpening(object sender, RoutedPropertyChangingEventArgs
{
// AutoCompleteBox is not focused, do NOT open drop-down
if (!SourceStationFocused)
e.Cancel = true;
}
//------------------------------------------------------------------------------------------
//Search_Click
ProgressIndicator prog;
private void ApplicationBarSearchButton_Click(object sender, EventArgs e)
{
//Source station destination do not duplicate.
if ((SourceStation.Text != "" && DestStation.Text != "") && SourceStation.Text != DestStation.Text )
{
string url = "http://169.254.80.80/checkSearch.php";
Uri uri = new Uri(url, UriKind.Absolute);
StringBuilder postData = new StringBuilder();
postData.AppendFormat("{0}={1}", "sStationName", HttpUtility.UrlEncode(this.SourceStation.Text));
postData.AppendFormat("&{0}={1}", "sStationName", HttpUtility.UrlEncode(this.DestStation.Text));
WebClient client = default(WebClient);
client = new WebClient();
client.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
client.Headers[HttpRequestHeader.ContentLength] = postData.Length.ToString();
client.UploadStringCompleted += client_UploadStringCompleted;
client.UploadProgressChanged += client_UploadProgressChanged;
client.UploadStringAsync(uri, "POST", postData.ToString());
prog = new ProgressIndicator();
prog.IsIndeterminate = true;
prog.IsVisible = true;
prog.Text = "Loading....";
SystemTray.SetProgressIndicator(this, prog);
}

Thanattha BussapakPosted Nov 29, 2013, 5:57 AM
But, I want to add by StationName in MySQL
How I create list form database.
Satyapriya NayakPosted Nov 28, 2013, 1:45 PM