c# - How to add isolated storage -
i trying save image media libary.
this xaml.cs file
using system; using system.collections.generic; using system.io; using system.linq; using system.runtime.interopservices.windowsruntime; using windows.foundation; using windows.foundation.collections; using windows.ui.xaml; using windows.ui.xaml.controls; using windows.ui.xaml.controls.primitives; using windows.ui.xaml.data; using windows.ui.xaml.input; using windows.ui.xaml.media; using windows.ui.xaml.navigation; using system.collections.objectmodel; using windows.ui.xaml.media.imaging; // blank page item template documented @ http://go.microsoft.com/fwlink/?linkid=391641 namespace app5 { /// <summary> /// empty page can used on own or navigated within frame. /// </summary> public sealed partial class mainpage : page { public mainpage() { this.initializecomponent(); lstimage.itemssource = getallphotos(); this.navigationcachemode = navigationcachemode.required; } private imagesource getimagesource(string filename) { homecoming new bitmapimage(new uri(filename, urikind.absolute)); } private observablecollection<photo> getallphotos() { observablecollection<photo> photos = new observablecollection<photo> { new photo{photosource = getimagesource("http://winartstyle.com/wp8/set1/1_0002_10453.jpg")}, new photo{photosource = getimagesource("http://winartstyle.com/wp8/set1/1_0003_10443.jpg")}, //new photo{photosource = getimagesource("images/harish.jpg")}, //new photo{photosource = getimagesource("images/harishv.jpg")}, //new photo{photosource = getimagesource("images/abhi.jpg")}, //new photo{photosource = getimagesource("images/suprotim.jpg")}, //new photo{photosource = getimagesource("images/harishvalone.png")}, //new photo{photosource = getimagesource("images/pinal.jpg")}, //new photo{photosource = getimagesource("images/shaivi.jpg")}, new photo{photosource = getimagesource("images/shobhan.jpg")}, //new photo{photosource = getimagesource("images/vikram.jpg")}, //new photo{photosource = getimagesource("images/host.jpg")} }; homecoming photos; } private void savebutton_click(object sender, eventargs e) { } /// <summary> /// invoked when page displayed in frame. /// </summary> /// <param name="e">event info describes how page reached. /// parameter typically used configure page.</param> protected override void onnavigatedto(navigationeventargs e) { // todo: prepare page display here. // todo: if application contains multiple pages, ensure // handling hardware button registering // windows.phone.ui.input.hardwarebuttons.backpressed event. // if using navigationhelper provided templates, // event handled you. } } } this xaml
<page x:class="app5.mainpage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:app5" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:ignorable="d" fontfamily="{staticresource phonefontfamilynormal}" foreground="{staticresource phoneforegroundbrush}" background="{themeresource applicationpagebackgroundthemebrush}"> <grid x:name="layoutroot" background="transparent"> <grid.rowdefinitions> <rowdefinition height="auto"/> <rowdefinition height="*"/> </grid.rowdefinitions> <stackpanel x:name="titlepanel" grid.row="0" margin="12,17,0,28"> <textblock x:name="applicationtitle" /> </stackpanel> <grid x:name="contentpanel" grid.row="1" margin="12,-20,12,0"> <listbox x:name="lstimage" margin="0,-20,0,0"> <listbox.itemtemplate> <datatemplate> <stackpanel orientation="horizontal"> <image source="{binding photosource}" /> </stackpanel> </datatemplate> </listbox.itemtemplate> </listbox> </grid> </grid> <page.bottomappbar> <commandbar issticky="true" > <appbarbutton icon="save" label="save" x:name="savebutton" click="savebutton_click" /> </commandbar> </page.bottomappbar> </page> i tried this
private void savebutton_click(object sender, eventargs e) { using (var store = isolatedstoragefile.getuserstoreforapplication()) { if (!store.fileexists(system.io.path.combine()) || store.fileexists(system.io.path.combine( )) && messagebox.show("overwrite file?", "question", messageboxbutton.okcancel) == messageboxresult.ok) { using (var stream = store.createfile(system.io.path.combine( ))) { stream.write(_imageasbyte, 0, _imageasbyte.length); } } } } # endregion public byte[] _imageasbyte { get; set; } } } but didn't work
i utilize help problem. going have many images loading webpage , if 1 can save phone , utilize background lockscreen or start screen
c# xaml windows-phone-8.1
No comments:
Post a Comment