content pannel is a grid, is like body in html
grid
canvas
stack pannel
if you want to put your control in center
horizontal,vertical alignment-->stretch and remove the margin
grid
--------
<grid>
<grid.rowdefinitions>
<rowdefinfinition height="80"/>
<rowdefinfinition height="80*"/> --->additional space
</grid.rowdefinitions>
<grid.columndefinitions>
<columndefinition height="100"/>
<columndefinition height="100*"/> --->additional space
</grid.columndefinitions>
<Button: width="" height="" content="" grid.row="0" grid.column="1"/>
</grid>
<stackpanel>(in new page)
----------------
all the controls in stackpanel will be in vertical
<canvas>(in new page)
if you want to place controls in various places then canvas will be the choice.
silverlight events
----------------------------------
for eg:
2 buttons pointed to same event to identify which button user clicks
< button height="" width="" content="button1" click="button1_click"/>
< button height="" width="" content="button2" click="button1_click"/>
under button1_click event handler
--------------------------------
button b = (button)sender;
textblock.text = n.name;
silverlight input controls
------------------------------
<scorllviewer viewer height="" width="" margin="0,0,0,0" verticalscrollbarvisibility="visible">
if you add any control in this it is better
</scorllviewer>
image control
--------------------
drag the image and set the datasource property from the property window
remember the path:/images;component(refer to xapfile)/images.koala.jpg
stretch property set to uniform from properties window
under load_click
-----------------
<scrolviewer margin="" scrollbarvisibility=visible">
BitmapImage IMA = NEW BitmapImage(new uri("/images;component/images/penguins.jpg",urikind.relative));
image1.source = ima;
</scrollviewer>
Resources and styles
--------------------------
theme resources for windows phone(bing)--------->binding syntax
eg: <button ------------------- borderbrush="{staticresource -----------}"
to use the same foreground property to same another button follow the steps
go to property window---->foreground rt click exctract-> key:somename destination:yourwish
if you want to create style
-------------------------------
<phone:phoneApplicationPae.Resources>
<style x:key="ravistyle" target="button">
<setter property ="borderbrush" value="red"/>
<setter property ="foreground" value="red"/>
</style>
</phone:phoneApplicationPae.Resources>
<button ------------------style="{staticresource ravistyle}"/>
Navigating b/w pages:
-----------------------------
Navigateuri(from properties window) = /projectname/component/page1.xaml
passing info b/w pages
------------------------
first page
Navigateuri(from properties window) = /projectname/component/page1.xaml?id=1
reading value in another page
=============================
underloaded event
-------------------
textbox1.text = string.format("value:{0}",navigationcontext.querystring["id"]);
when we reading the qierystring in another page(if the value not comes to that page then(safty precation))
stirng id="";
if(NavigationContext.Querystring.TryGetvalue("id",out id))
{
textbox1.text = string.format("value:{0}",id);
}
maiantaing state in textbox when we navigating other pages
-------------------------------------------------------------
under mainpage.xml.cs
-----------------------
protected override void onNavigatedFrom(System.windows.Navigation.NavigationEventsArgs e)
{
phoneAppService.State["myvalue"] = textbox1.text;
base.OnNavigatedFrom(e);
}
protected override void onNavigatedTo(System.windows.Navigation.NavigationEventsArgs e)
{
object someobject;
if(phoneAppservice.State.ContainsKey("myvalue"))
{
if( phoneAppService.State.TryGetvalue("myvalue",out someobject))
{
textbox1.text = someobject.tostring();
}
}
base.onnavegatedTo(e);
}
application bar
-------------------------
c:\programfiles\microsoftsdks/windows7/versoin7/dark/ (to findout images like + ,- ?)
build action = content(mandatory)
remove the comments on application bar code in source code
set the iconruri = your path
using cnavas dialog(important visible and collapse)
-------------------------------------------
<button--------------------- click=openbutton_click/>
//to creata a dialog
<canvas ---------------visibility="collapsed"/>
<textblock-----------------/>
<button----------------------/>
</canvas>
under openbutton_click
---------------------
mydialog.visibility = system.windows.visibility.visibile;
under clostbutton_click
----------------------
mydialog.visibility = system.windows.visibility.collapse;
isolated storage:
-----------------------------
under save_click
--------------------
var appstorage = isolatedstorageFile.getuserstorageforapplication();
string filename = "ravi.text";
using (var file = appstorage.openfile(filename,system.io.filemode.openorcreate,system.io.fileassceess.write))
{
using (var writer = new streamwriter(file))
{
writer.write(textbox1.text);
}
}
under open_clcik
---------------------
using (isolatedstoragefile store = isolatedstoragefile.geruserforapplication())
{
using (streamreader sr = new streamreader(store.openfile("ravi.text",filemode.open,fileaccess.read)))
{
textbox1.text = sr.readtoend();
}
}
note: when your shutdown or pc then the data in isolated area will be arased
isolated listbox and templates
---------------------------------
take one listbox in grid_content(source code)
<listbox----------------->
<listbox.itemtemplate>
<datatemplate>
<hyperlinkbutton name="" content"{binding}" click="filename_linkbutton_click"/>
</datatemplate>
</listbox.template>
</listbox>
<button content="load samples"----------- click="loadsamplesbutton_click"/>
under loadsamplesbutton_click
-----------------------------
var appstorage = isolatedstoragefile.getuserstoreforapplication();
if(!appstorage.fileexists("text1.txt"))
{
using (var file = appstorage.createfile("text1.txt"))
{
using (var writer = new streamwriter(file))
{
writer.writeline("this is the first test");
}
}
}
private void loadsamplesbutton_click(object sender,routedeventargs e)
{
createsamples("test1.txt","this is the first test");
createsamples("test2.txt","this is the secound test");
createsamples("test3.txt","this is the third test");
bindlist();
}
//helper method
----------------
private void createsample(string filename,string filecontent)
{
var appstorage = isolatedstoragefile.getuserstoreforapplication();
if(!appstorage.fileexists(filename))
{
using (var file = appstorage.createfile(filename))
{
using (var writer = new streamwriter(file))
{
writer.writeline(filecontent);
}
}
}
}
phoneapplicationpage_loaded event
{
bindlist();
}
//helper method
private void bindlist()
{
var appstorage = isolatedstoragefile.getuserstoreforapplication();
string[] filelist = appstorage,getfilename();
filelistbox.itemsource = filelist;
}
under filenamelinkbutton_click
--------------------------------
hyperlinkbutton h = (hyperlinkbutton)sender;
string uri = string.format("isolatedstoragelisting;component;/secondpage.xml?id={0}", h.content);
Navigationservice.navigae(new uri(uri,uriking.relative));
under secondpage
---------------------------
under loaded event
--------------------
var appstorage = isolatedstoragefile.getuserstoreforapplication();
string filename = NavigationContext.querystring["id"];
using (streamreader sr = new streamreader(appstorage.openfile(filename,system.io.filemode.open))
{
displaytextblock.text = sr.readtoend();
}
to know the isolate storage(how much place availble)
-----------------------------------
textbox1.text = string.format("free:{0}",appstorage.availablefreespace.tostring());
textbox2.text = string.format("quota:{0}",appstorage.quota.tostring());
maintaing state when navigating b/w pages(backbutton and start button event though emulator closed we will get the
information back which is stored in isolated storage)--->toomstoning
===========================
phoneapplicationservice phoneappservice = phoneapplicationservice .current;
under textchanged event
----------------------------
{
phoneappservice.state["myvalue"] = textbox.text;
}
under loaded event
----------------------
object myvalue;
if(phoneappservice.state.containskey("myvalue")
{
if(phoneappservice.state.trygetvalue("myvalue",out myvalue))
{
textbox.text = myvalue.tostring();
}
}
under appxaml.cs
---------------------
helpermethod
-------------
privat void savestate()
{
phoneapplicationservice phoneappservice = phoneapplicationservice .current;
isolatedstoragesetting settings = isolatedstoragesettings.applicationsettings;
settings["myvalue"] = phoneappservice.state["myvalue"];
}
private void loadstate()
{
phoneapplicationservice phoneappservice = phoneapplicationservice .current;
isolatedstoragesetting settings = isolatedstoragesettings.applicationsettings;
string myvalue = "";
if(settings.trygetvalue<string>("myvalue",out myvalue))
{
phoneappservice.state["myvalue"] = myvalue;
}
}
appliction_launching
---------------------
loadstate()
application_activated
----------------------
loadstate()
application_deactivate and application_closing
-----------------------------------------------
savestate()
-------------------------------------------------------------------------------------------------------------------
adding different inputscopes
ref: inputscopenamevalue enumeration(bing)
<textbox ----------------->
<textbox.inputscopt>
<inputscope>
<inputscopename =namevalue="text"/>
</inputscope>
</textbox.inputscopt>
</textbox>
-------------------------------------------------------------------------------------------------------------------
gps:
-----------
add reference----------> system.device
namespace: using system.device.loaction
under button_click
---------------------
geocoorenatewatcher mywatcher = new geocoorenatewatcher ();
var myposition = mywatcher.position;
double latitude = 47.674;
double longitude = -122.12;
if(!myposition.location.isknown)
{
latitude = myposition.location.latitude;
longitude = myposition.location.longitude;
}
http://msrmaps.com/webservice.aspx-----------------(free websericess)
how to access service in client
--------------------------------
servicereference1client client = new servicereference1client ();
client.convertlonlarpttonearestplacecompleted + - press tab tab ;
client.convertlonlarpttonearestplaceasync(new servicereference1.lonlanpt{lan = latitude,lon = longitude});
void someevent (it will automatically generate
{
textbox1.text = e.result;
}
-------------------------------------------------------------------------------------------------------------------
changing background
----------------------
supprotedorientation property set to portrteorlanscape
under edit_click
----------------
if(textbox1.visibility == system.windows.visibility.visible)
{
button.content = "edit";
textblock1.text = textbox1.text;
textbox1.visibility = system.windows.visibility.collapsed;
textbolck1.visibility = system.windows.visibility.visible;
}
else
{
button.content = "save";
textbox1.text = textblock1.text;
textbox1.visibility = system.windows.visibility.visible;
textbolck1.visibility = system.windows.visibility.collapsed;
}
SQL Style ID SQL Style Example
0 or 100 mon dd yyyy hh:miAM (or PM) Jan 15 2008 5:44PM
101 mm/dd/yy 01/15/2008
102 yy.mm.dd 2008.01.15
103 dd/mm/yy 15/01/2008
104 dd.mm.yy 15.01.2008
105 dd-mm-yy 15-01-2008
106 dd mon yy 15 Jan 2008
107 Mon dd, yy Jan 15, 2008
108 hh:mm:ss 17:42:33
9 or 109 mon dd yyyy hh:mi:ss:mmmAM (or PM) Jan 15 2008 5:42:09:953PM
110 mm-dd-yy 01-15-2008
111 yy/mm/dd 2008/01/15
112 yymmdd (no spaces) 20080115
13 or 113 dd mon yyyy hh:mm:ss:mmm(24h) 15 Jan 2008 17:37:13:163
114 hh:mi:ss:mmm(24h) 17:37:52:407
20 or 120 yyyy-mm-dd hh:mi:ss(24h) 2008-01-15 17:38:20
21 or 121 yyyy-mm-dd hh:mi:ss.mmm(24h) 2008-01-15 17:38:44.867
126 yyyy-mm-dd Thh:mm:ss.mmm(no spaces) 2008-01-15T17:39:12.193
No comments:
Post a Comment