I want each pivot item to be one directory in isolated storage then load every file name into a listbox I find it quite confusing , can you guys help me with it?
Currently its all just showing in one pivot & for my app, user can actually create a pivot aka directory.
will it be possible to create a code in a way where i can i will load the directory based on the pivotitem name then load all item from that directory?
Thanks >.<
public partial class View2 : PhoneApplicationPage
{
public String selected;
public View2()
{
InitializeComponent();
LoadFromLocalStorage();
}
private void LoadFromLocalStorage()
{
try
{
using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication())
{
//string[] fileNames = store.GetFileNames();
string[] fileNames = store.GetFileNames("./general/*.*");
var files = new ObservableCollection<string>();
foreach (string s in fileNames)
{
files.Add(s);
}
lbFiles.ItemsSource = files;
}
}
catch
{
MessageBox.Show("Capture an image first!");
}
}
private static string _first;
public string First
{
get
{
return _first;
}
}
private void lbFiles_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
selected = lbFiles.SelectedItem.ToString();
general item = new general();
item.viewimage(selected);
MessageBox.Show(selected);
_first = selected;
NavigationService.Navigate(new Uri("/View.xaml", UriKind.Relative));
}
}
For creating one pivot item for each directory, its better if you can create a class for the same, name say “DirectoyItem” which has the name and a collection of file’s(call it as Files) name in that directory.
For better modularity and clarity create a Viewmodel for the page which has the Collection( ObservableColelction is most preferred) of “DirectoryItem”. call this collection as Directories
public class ViewModel
{
ObservableCollection Directories = new ObservableColelction();
}
public class DirectoryItem:INotifyPropertyChanged
{
string _name;
}
Bind this collection items to the PivotControl items.
you can do so , as follows
set the datacontext something like this in page constructor
By doing this you will create a page which has the pivot controls whose items are the directories of the Isolated storage and each pivot item has the names of the files in that particular directory.