ScriptObject script = (ScriptObject)HtmlPage.Window.GetProperty("ChangeImg");
script.InvokeSelf();
İlk satırda sayfasımızda yer alan ChangeImg adlı fonksiyona erişiyoz ve alt satırda bu fonksiyonu çalıştırıyoruz.
Eğer parametre göndermek istersek;
script.InvokeSelf("par1","par2");
Tuesday, January 20, 2009
Monday, January 19, 2009
Read A Xml Document With Silverlight(XLINQ)
private void btnSend_Click(object sender, RoutedEventArgs e)
{
string uri = Application.Current.Host.Source.AbsoluteUri;
int index = uri.IndexOf("/ClientBin");
uri = uri.Substring(0, index);
txtAd.Text = uri;
WebClient client = new WebClient();
client.DownloadStringAsync(new Uri(uri+"/data.xml"));
client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_DownloadStringCompleted);
}
okuma tamamlandığında ise;
void client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
try
{
XElement element = XElement.Parse(e.Result);
txtAd.Text = (from x in element.Descendants("musteri")
select x.Element("ad").Value).First();
}
catch (Exception ex)
{
System.Windows.Browser.HtmlPage.Window.Alert(ex.InnerException.Message);
}
}
{
string uri = Application.Current.Host.Source.AbsoluteUri;
int index = uri.IndexOf("/ClientBin");
uri = uri.Substring(0, index);
txtAd.Text = uri;
WebClient client = new WebClient();
client.DownloadStringAsync(new Uri(uri+"/data.xml"));
client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_DownloadStringCompleted);
}
okuma tamamlandığında ise;
void client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
try
{
XElement element = XElement.Parse(e.Result);
txtAd.Text = (from x in element.Descendants("musteri")
select x.Element("ad").Value).First();
}
catch (Exception ex)
{
System.Windows.Browser.HtmlPage.Window.Alert(ex.InnerException.Message);
}
}
Silverlight Send Parameter And Start Random Page
string sayfaAdı=e.InitParams["ad"]
var myPage=(UserControl)this.GetType().Assembly.CreateInstance(this.GetType().Namespace + "." + ad);
this.RootVisual = myPage;
veya daha kolay olarak girilen parametreye sayfayı belirleriz.
switch (ad)
{
case "Page1":
this.RootVisual = new Page1();
break;
case "Page2":
this.RootVisual = new Page2();
break;
default:
this.RootVisual = new Page();
}
var myPage=(UserControl)this.GetType().Assembly.CreateInstance(this.GetType().Namespace + "." + ad);
this.RootVisual = myPage;
veya daha kolay olarak girilen parametreye sayfayı belirleriz.
switch (ad)
{
case "Page1":
this.RootVisual = new Page1();
break;
case "Page2":
this.RootVisual = new Page2();
break;
default:
this.RootVisual = new Page();
}
Silverlight ve font embed
Fontu projenize ekledikten sonra fontun Visual Studio'da özellikler kısmına gelip "Build Action" kısmından "Resources" i seçiniz.
Daha sonra bu fontu kullanacağımız elemente aşğıdakini yazınız;
FontFamily="consola.ttf#Consolas"
Daha sonra bu fontu kullanacağımız elemente aşğıdakini yazınız;
FontFamily="consola.ttf#Consolas"
Sunday, January 18, 2009
Silverlight And Path Files
var path = new Uri("http://" + System.Windows.Browser.HtmlPage.Document.DocumentUri.Host + "/videos/" + cmb_videos.SelectedItem.ToString());
Subscribe to:
Posts (Atom)