Part 22: Animating the Reel Grid with a Storyboard

Sign in to queue

The Discussion

  • User profile image
    ZhouningMan

    I love your videos!!!

  • User profile image
    BobTabor

    @ZhouningMan: Smiley  I love your comments.

  • User profile image
    shenzhongwei

    Could the Blend for VS an option for manipulating the animation? Anyway,  I like this tutorial very much.

  • User profile image
    mackenzie

    This video series is wonderful. I was already thinking about putting images as the background tile for the sounds as my kid loves this app. It took my brain more time to figure it out than it took to actually code it. 

    The toolset in this app's series alone is enough to make a wide variety of other apps.

    Thanks!!!

  • User profile image
    BobTabor

    @shenzhongwei: Yes, in fact I think that Clint started down that path originally when working with the animation bits.  There were some things left over from Blend that I took out and just coded by hand.  HOWEVER, I'm not a Blend guy and someone else might do a better job explaining how you could create an animation in Blend then apply it using C#.

    @mackenzie: Yes, Clint did a nice job blowing out the functionality to include a lot of concepts.  Thanks!

  • User profile image
    Shinto

    @BobTabor Great work!

  • User profile image
    Pasteur

    I'm an iOS Developer trying to learn WP8, but being an "Apple guy" Microsoft technologies and ways of doing things are admittedly very foreign to me. So far, this series has been a goldmine in helping me bridge the knowledge gap. Bob, you are a fantastic instructor, and I hope you plan to do more of these videos in the future.

    1/3 of the "extra" tasks done (pin to start), and now to see if I can tackle the rest.

  • User profile image
    BobTabor

    @Shinto: Thanks!

    @Pasteur: Awesome feedback.  Smiley  Glad this is helping ... I think you are exactly the kind of person Microsoft wants to recruit with this series.

  • User profile image
    Progr

    Hey, Bob! I don't speak english very well, but your lessons are great! Thank you wery much!
    And I have a question to you: I want to create an animation - page rotating when PhoneApplicationPage orientation changed. But i don't understand how can i do this with storyboard object. Can you help me, please?

  • User profile image
    Clint
  • User profile image
    Progr

    @Clint, Thank you very much!

  • User profile image
    mvpspl619

    Hey @Clint @BobTabor,

    I am trying to add an option to delete the customaudio file. The context menu seems good. And I even added a messagebox asking to confirm whether they really want to delete the file. 

    private void Delete_Click(object sender, RoutedEventArgs e)
            {
                //Check which object the event is passing here ?
    
                var selected = (sender as SoundData) as SoundData;
    
                //SoundData data = selected.SelectedItem as SoundData;
    
                MessageBoxResult result = MessageBox.Show("Do you want to delete this item ?", "Are you sure ?", MessageBoxButton.OKCancel);
                if (result == MessageBoxResult.OK)
                {
                    if (selected == null)
                    {
                        MessageBox.Show("The file doesn't exist");
                        return;
                    }
                    //Check if the file exists at location
                    if (File.Exists(selected.FilePath))
                    {
                        MessageBox.Show("Wav will be deleted");
                    }
                    else
                    {
                        using (var storageFolder = IsolatedStorageFile.GetUserStoreForApplication())
                        {
                            using (var stream = new IsolatedStorageFileStream(selected.FilePath, FileMode.Open, storageFolder))
                            {
                                //storageFolder.DeleteFile();
                            }
                        }
                    }
                }
                else
                {
                    return;
                }
                //delete it
                //update the pivot page
            }

    This is the code that I am using. There are multiple problems here.

    1. I don't exactly understand how to pass the clicked wav file SoundData data to the Delete_Click event. If I can successfully pass it, then I can check if it is valid and then I can go on and delete it. Kindly put me in the right direction on how to pass the SoundData of the longclicked wav file. I don't think I can use the SelectionChangedEvent here because it is a contextmenu and it doesnt have the right attribute. Correct me if I am wrong.

    2. After I get the data, I can just refer to the item.FilePath property to know the location and delete it ? Or do I have to use the IDisposable approach to manage the resources properly and then use IsolatedStorageFile to look into the directory and then delete the file ? Please just give me hints so that I can make up with a solution myself.

    And I remember Bob saying that we'll receive more hints about contextmenu and etc in the later videos, but sincerely I don't want to wait. I want to add an option to delete customaudio files in my soundboard app and then only move on with the tutorial.

    EDIT: Right now when I test the app to delete the wav, it says "The file doesn't exist".

  • User profile image
    Clint

    @mvpspl619: first, we're really trying to keep questions only to the topic of the video.  We love the fact you're building an application but have to keep the comments to the video.

    Rewatch / read https://channel9.msdn.com/Series/Windows-Phone-8-Development-for-Absolute-Beginners/Part-15-Playing-a-Sound-when-a-ListItem-is-Selected  We leverage the SelectionChanged event.  We see what the SelectedItem was on LongListSelector then reset it back to null.  (See #3).  I'd also actually rethink how you're doing deleting as well and make it work like Windows Phone with a context menu or a multi-select long list selector.  See / try out the Photo in WP8.  Both of these controls are in the WPToolkit (http://phone.codeplex.com).  We also talk about this toolkit a bit later on in the series.

  • User profile image
    mvpspl619

    Thank you, I will follow what you said. Only reason I asked my query here is because Bob suggested to add the images to tiles and option to delete using context menu in this video as it is the end of developing SoundBoard app. 

    Thanks anyway.  Smiley

  • User profile image
    rfreytag

    Here an idea - make the reel rotate _backwards_ when the user presses the 'play' button and stop rotating when the sound stops without making it a toggle button (no second button press!). 

    Hint: you'll need: www.silverlightshow.net/items/How-to-invoke-method-in-the-UI-thread.aspx

    Email me at WP8DfAB-ch22 (at) Freytag.org if needed. 

  • User profile image
    Clint

    @rfreytag: neat idea, I thought about the UI and how best to make it for a beginner to develop.  bringing in the Dispatcher and UI vs background threads starts getting confusing for someone new to the platform.

  • User profile image
    rfreytag

    @Clint - I see your point.  While what I implemented above works fine my next stunt did not.  I tried implementing a 'click and hold' event using a MouseLeftButtonDown + MouseLeftButtonUp + Timer and got hung up on another cross-thread exception.  Clearly I have more to learn. 

  • User profile image
    Clint
    @rfreytag: use the tap or hold event. Don't reinvent user expectation behaviors as well Smiley
  • User profile image
    AnhDuong

    I can pin the sounds to the start screen but the new tile only displays the Title of the sound and it only navigates users to the MainPage.xaml when users tap on it.
    I guess by "pinning the sound to start screen", Bob meant that we can play the sound directly on the start screen by tapping on it.
    I've done some research about secondary tiles but nothing like "playing audio using secondary tile" came up. Any suggestion?

    Thank you for reading this. Any help is appreciated.

  • User profile image
    Clint
    @AnhDuong: we didn't cover pinning in this series. While it is awesome you are extending the app, We are trying to keep the comments to the topic covered in the video. that said, I suggest looking at stackoverflow.com. They without a doubt talk about this along with dev.windowsphone.com. Big this is note your query string on the pinned tile
  • User profile image
    habula

    Hi,

    I am getting the following error when click the record button (around 12:50 in video timing).

    System.InvalidOperationException was unhandled by user code
    HResult=-2146233079
    Message=Cannot resolve TargetProperty (UIElement.RenderTransfom).(CompositeTransform.Rotation) on specified object.
    Source=System.Windows
    StackTrace:
    at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
    at MS.Internal.XcpImports.Storyboard_Begin(Storyboard storyboard)
    at System.Windows.Media.Animation.Storyboard.Begin()
    at SoundBoard.RecordAudio.RecordAudioChecked(Object sender, RoutedEventArgs e)
    at System.Windows.Controls.Primitives.ToggleButton.OnChecked(RoutedEventArgs e)
    at System.Windows.Controls.Primitives.ToggleButton.OnIsCheckedPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
    at System.Windows.DependencyObject.RaisePropertyChangeNotifications(DependencyProperty dp, Object oldValue, Object newValue)
    at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)
    at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet)
    at System.Windows.Controls.Primitives.ToggleButton.OnToggle()
    at System.Windows.Controls.Primitives.ToggleButton.OnClick()
    at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
    at System.Windows.Controls.Control.OnMouseLeftButtonUp(Control ctrl, EventArgs e)
    at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName)
    InnerException:

    I researched on internet as well but no help on that. This is present in the file RecordAudio.xaml

    <phone:PhoneApplicationPage.Resources>
    <Storyboard x:Name="RotateCircle" RepeatBehavior="Forever">
    <DoubleAnimation
    Duration="0:0:4"
    To="360"
    Storyboard.TargetProperty="(UIElement.RenderTransfom).(CompositeTransform.Rotation)"
    Storyboard.TargetName="ReelGrid"
    d:IsOptimized="True" />
    </Storyboard>
    </phone:PhoneApplicationPage.Resources>

  • User profile image
    Clint

    @habula: well, lets work on reading what that exception says.  Basically it says the storyboard is invalid because it can't figure out where the CompositeTransform.Rotation is on "ReelGrid".

    This makes me wonder did you add in RenderTransform into the XAML (more or less the first step from the text)?

    <Grid 
        Name="ReelGrid"
        Height="200" 
        Width="200"
        RenderTransformOrigin=".5, .5" >
        <Grid.RenderTransform >
            <CompositeTransform/>
        </Grid.RenderTransform>

    Also, when you hit stuff like this, compare your code to our code.  Each lesson has a dedicated snapshot of the source code Smiley

  • User profile image
    habula

    Hi Clint,

    Thanks for the response. Actually there was a spelling mistake. We looked again at the error message carefully (Message=Cannot resolve TargetProperty (UIElement.RenderTransfom).(CompositeTransform.Rotation) on specified object.) and realized that it should be Transform. Once again thank you for your time Smiley .

  • User profile image
    Clint

    @habula: no problem.  glad it is resolved now!

  • User profile image
    RazaNaqvi

    Hi Clint,

    I'm trying to implement the delete functionality with a ContextMenu and I had some questions around it. You've mentioned in the comments above that you'd like to limit the comments here to the material covered in the tutorials, so I was wondering if there's a different place here that we can ask questions related to extending the functionality of the app, any issues encountered and design related questions? Great series, BTW. I've been meaning to get into Windows Phone app development for a while and this was the perfect place to start.

    Raza.

  • User profile image
    Clint

    @RazaNaqvi: Hey Raza, we really don't have a place dedicated to this.  one place would be the channel 9 coffee house forums.  If you are running into problems with APIs, I suggest http://dev.windowsphone.com and www.stackoverflow.com

  • User profile image
    StepTNT

    I'm trying to add the features suggested at the end of the video but I'm having some problems.

    I've thought to use a ContextMenu to make the "Pin to start" and the "delete sound" stuff, so this ContextMenu has two MenuItem and each one should call a different method. Of cours I've put the ContextMenu inside the SoundTileDataTemplate, so that each tile has this context menu.

    Now, here's the problem: how can I pass the SoundData to the method to correctly delete it?

    If I use the Tap event, there's no way to pass parameters using XAML (and I can't even navigate to the LongListSelector's selected item because the highest parent of the MenuItem is the Popup which hasn't any parent).

    I've found something online using Command and CommandParameter but I've got no idea on how to make it work.

     

    As a side question, is there any way to enable the second MenuItem only if we're working with the custom sounds?
    Something like a conditional rendering for that item, based on the lists' item type?

     

    Thank you Smiley

  • User profile image
    Clint

    @StepTNT: while I think it is amazing you're extending the application, I have to keep the responses to the topic covered in the video.  I suggest asking the questions over at https://dev.windowsphone.com or www.stackoverflow.com

  • User profile image
    StepTNT

    @Clint: I know, but StackOverflow is not WP friendly Sad I'll head to dev.windowsphone.com, have a nice day Smiley

  • User profile image
    Clint

    @StepTNT: really?  I've never had an issue with stackoverflow.  Could you email me an example where you've had a bad experience asking a question?  clint.rutkas@microsoft.com

  • User profile image
    manyasone

    I love this series (and did love the C#-series as well) because of the thorough structure and clear instructions! Smiley

    The SoundBoard-app works just fine on the emulator for me, but now I've run into a problem, when running this app on a Windows 8 Phone: When I try to save a custom sound, I get an error on line 78 of the RecordAudio.xml.cs (isoStore.MoveFile-statement), even when using your version of the app:

    isoStore.MoveFile(_tempFileName, soundData.FilePath);

    The error message:

    System.IO.IsolatedStorage.IsolatedStorageException was unhandled by user code
      HResult=-2146233264
      Message=Operation not permitted.
      Source=mscorlib
      StackTrace:
           at System.IO.IsolatedStorage.IsolatedStorageFile.MoveFile(String sourceFileName, String destinationFileName)
           at SoundBoard.RecordAudio.FileNameCompleted(Object sender, PopUpEventArgs`2 e)
           at Coding4Fun.Toolkit.Controls.PopUp`2.OnCompleted(PopUpEventArgs`2 result)
           at Coding4Fun.Toolkit.Controls.UserPrompt.OkClick(Object sender, RoutedEventArgs e)
           at System.Windows.Controls.Primitives.ButtonBase.OnClick()
           at System.Windows.Controls.Button.OnClick()
           at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
           at System.Windows.Controls.Control.OnMouseLeftButtonUp(Control ctrl, EventArgs e)
           at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName)
      InnerException:

    Since the error message says "Operation not permitted", I guess the app doesn't have permission to write new files? But how do I grant that permission?
    (It's a Nokia id101 Lumia developer device).

    Thanks, Simon

  • User profile image
    Clint

    @manyasone: does our version of the application work for you?

  • User profile image
    manyasone

    with your "soundboard_complete_from_videos" i've got the same problem: it works with the emulator, but not with the phone.

    (edit: everything but saving a custom sound works with the phone; when i tip the disc icon, i get the error message)

  • User profile image
    Clint

    @manyasone: is this app you made or the sample source code we provide on codeplex?

  • User profile image
    Clint

    @manyasone: I think it could be a double click on the OK button.  I could only get this to happen once and on my very first try.

  • User profile image
    AnthonyLaw

    @BobTabor :Really Really great video for the tutorial Smiley
    i am the information System Engineering Degree student, taking Final Year Project is about ~ Online Audio distribution. (it's challenge to build an WP8 apps)
    Like people can record their own audio and share to the world.

    Your tutorial help me a lot, i'm totally new in to build the Mobile apps.
    Since in the tutorial is Local Apps, have any suggestion video to build apps is online base?
    such as using WCF to sent and retrieve data from online database?

  • User profile image
    Clint

    @AnthonyLaw:  There are a ton of online resources for building those style applications.  Right now for absolute beginners, our current list is: https://channel9.msdn.com/posts/Beginner

  • User profile image
    YueDaWei

    Hi, first thanks for you guys contributing this series.

    Somehow, I have a problem when I implement the feature of deleting one "mine" item, and no matter what i do it cannot refresh the custom page. I have re-loaded the data from IsolatedStorageSettings which has correct, and Navigate the Uri, but this doesn't work, the deleted item always lie here, when i click it, you know, the application crashes down.What issue do I miss?

    Thanks again.

  • User profile image
    Clint

    @YueDaWei: I'm not sure what you are doing and that is a feature that is outside the scope of the application we built.  I'd leverage the debugger and start stepping through your code and validating what you are doing.  Mimic what we did to add items to the settings, just flip it from adding to removing.

  • User profile image
    arojaspa

    @mvpspl619:Hello.. I tried this code and it works for me:

    1. Create a new page with a pivot page template

    <!--LayoutRoot is the root grid where all page content is placed-->

    <Grid x:Name="LayoutRoot" Background="Transparent">

    <phone:Pivot Title="{Binding Path=LocalizedResources.ApplicationTitle, Source={StaticResource LocalizedStrings}}">

    <phone:PivotItem Header="delete files">

    <phone:LongListSelector x:Name="LLCustomFiles"

    LayoutMode="List"

    SelectionChanged="DeleteCustomFilesListSelector_SelectionChanged"

    ItemTemplate="{StaticResource DeleteCustomFilesTemplate}"

    >

    </phone:LongListSelector>

    </phone:PivotItem>

    </phone:Pivot>

    </Grid>

    2. Create a new local ítem template like the mainpage.xaml to binding information.

    <phone:PhoneApplicationPage.Resources>

    <DataTemplate x:Name="DeleteCustomFilesTemplate">

    <StackPanel Margin="0,0,0,17">

    <TextBlock Text="{Binding Title}" TextWrapping="Wrap" Style="{StaticResource PhoneTextExtraLargeStyle}"></TextBlock>

    <TextBlock Text="{Binding FilePath}" TextWrapping="Wrap" Margin="12,-6,12,0" Style="{StaticResource PhoneTextSubtleStyle}"></TextBlock>

    </StackPanel>

    </DataTemplate>

    </phone:PhoneApplicationPage.Resources>

    3. Create a event for LoongListSelector SelectionChanged. Here I'm going to send you the entire code begin for page created in point 1.

     

    using System;

    using System.Collections.Generic;

    using System.Linq;

    using System.Net;

    using System.Windows;

    using System.Windows.Controls;

    using System.Windows.Navigation;

    using Microsoft.Phone.Controls;

    using Microsoft.Phone.Shell;

    using SoundBoard.ViewModels;

    using System.IO.IsolatedStorage;

    using Newtonsoft.Json;

    using SoundBoard.Resources;

    namespace SoundBoard

    {

    publicpartialclassDeleteCustomFiles : PhoneApplicationPage

    {

    public DeleteCustomFiles()

    {

    InitializeComponent();

    LoadCustomFiles();

    BuildLocalizeApplicationBar();

    }

    privatevoid BuildLocalizeApplicationBar()

    {

    ApplicationBar = newApplicationBar();

    ApplicationBarIconButton homeAppBar =

    newApplicationBarIconButton();

    homeAppBar.IconUri = newUri("/Assets/AppBar/check.png", UriKind.Relative);

    homeAppBar.Text = AppResources.AppBarGoHome;

    homeAppBar.Click += homeAppBar_Click;

    ApplicationBar.Buttons.Add(homeAppBar);

    }

    void homeAppBar_Click(object sender, EventArgs e)

    {

    NavigationService.Navigate(newUri("/MainPage.xaml", UriKind.RelativeOrAbsolute));

    }

    privatevoid LoadCustomFiles()

    {

    SoundGroup data;

    string dataFromAppSettings;

    if (IsolatedStorageSettings.ApplicationSettings.TryGetValue(SoundModel.CustomSoundKey, out dataFromAppSettings))

    {

    data = JsonConvert.DeserializeObject<SoundGroup>(dataFromAppSettings);

    }

    else

    {

    data = newSoundGroup();

    data.Title = "delete files";

    }

    LLCustomFiles.ItemsSource = data.Items;

    }

    privatevoid DeleteCustomFilesListSelector_SelectionChanged(object sender, SelectionChangedEventArgs e)

    {

    LongListSelector selector = sender asLongListSelector;

    // verificando que nuestro sender sea in LongListSelector

    if (selector == null)

    return;

    SoundData data = selector.SelectedItem asSoundData;

    //verificamos que nuestro sender es un SoundData

    if (data == null)

    return;

    try

    {

    using (IsolatedStorageFile storageFile = IsolatedStorageFile.GetUserStoreForApplication())

    {

    storageFile.DeleteFile(data.FilePath);

    }

    // Remove the SoundData from App.ViewModel.CustomSounds

    int i = GetSoundDataIndex(data);

    App.ViewModel.CustomSounds.Items.RemoveAt(i);

    // Save the list of CustomSounds to IsolatedStorage.ApplicationSettings

    var dataSerialize = JsonConvert.SerializeObject(App.ViewModel.CustomSounds);

    IsolatedStorageSettings.ApplicationSettings[SoundModel.CustomSoundKey] = dataSerialize;

    IsolatedStorageSettings.ApplicationSettings.Save();

    // We'll need to modify our SoundModel to retrieve CustomSounds

    // from IsolatedStorage.ApplicationSettings

    NavigationService.Navigate(newUri("/MainPage.xaml", UriKind.RelativeOrAbsolute));

    }

    catch (IsolatedStorageException ex)

    {

    MessageBox.Show(ex.Message);

    }

     

    }

    privateint GetSoundDataIndex(SoundData data)

    {

    List<SoundData> listSound = App.ViewModel.CustomSounds.Items;

    int iReturn = 0;

    for (int i = 0; i < listSound.Count; i++)

    {

    if (listSound[i].FilePath.Equals(data.FilePath))

    {

    iReturn = i;

    break;

    }

    }

    return iReturn;

    }

    }

    }

    I hope this piece of code works for you.

     

    Regards,

     

    Andres Rojas

    MVP SharePoint

  • User profile image
    feraask

    Hey Bob, love the series so far! Really helpful in learning windows phone development :)

    I've been trying out the recording app and I think I've found a bug that isn't talked about in the video. For some reason whenever I try to play a piece of custom audio that I recorded for a second time I am getting the following exception:
    "An exception of type 'System.IO.IsolatedStorage.IsolatedStorageException' occurred in mscorlib.ni.dll but was not handled in user code"

    on the line:
    using (var stream = new IsolatedStorageFileStream(data.FilePath, FileMode.Open, storageFolder))

    inside the LongListSelector_SelectionChanged method in MainPage.xaml.cs

    I've tried it on the provided complete source code that I downloaded as well and it has the same bug although I have no clue why it is happening. Any ideas?

  • User profile image
    feraask

    Well I was able to fix the issue by creating a private instance field in the MainPage.xaml.cs which holds the filePath of the last played audio file which I then use to compare with the new filePath every time the user clicks on a tile to play the audio and if the file's are the same I just call the AudioPlayer.Play() method for the media element instead of reopening the filestream or setting up the URI again. Basically:

    if (data.FilePath.Equals(lastFilePath))
    AudioPlayer.Play();
    else
    {
    lastFilePath = data.FilePath;
    if (File.Exists(data.FilePath))
    {
    AudioPlayer.Source = new Uri(data.FilePath, UriKind.RelativeOrAbsolute);
    }
    else
    {
    using (var storageFolder = IsolatedStorageFile.GetUserStoreForApplication())
    {
    using (var stream = new IsolatedStorageFileStream(data.FilePath, FileMode.Open, storageFolder))
    {
    AudioPlayer.SetSource(stream);
    }
    }
    }
    }

    Although this is somewhat of a "hacky" fix I cannot for the life of me figure out what is causing it to crash the second time you play a custom audio file. (I think it has to do with the file stream remaining Undisposed and then trying to open it again i.e. opening the same file stream twice or something but I'm not sure why...) From the method stub of the IsolatedStorageFileStream description the only ways for it to throw an exception are:

    isf has been disposed. -or- Path is badly formed. -or- Path is null. -or- Isf is null. -or- The directory in path does not exist.-or- No file was found and the mode is set to System.IO.FileMode.Open.

    but stepping through the debugger I can see all the values passed into the method are the same from the first time the click event is called and the second time where it throws the exception. In any case I'm glad to have at least found a fix for anyone else who has the issue. Hope this helps!

  • User profile image
    SA24

    Did anyone manage to add images to the "Tiles".. I'm new to the WP8 development, can anyone provide me the way forward to do this???

  • User profile image
    Aman

    Hi Bob,

    Just wanted to let you know I took on that challenge, and coded by myself deleting the custom items tile as well as the actual file, AND implemented a "Favorites" pivot item that you could add sounds to from any of the pages. That last part was really fun :)

    THANKS SO MUCH FOR THIS GUIDE!

  • User profile image
    BobTabor

    @Aman: Awesome!  Good for you!  I need to incorporate more of that sort of thing in the future.

  • User profile image
    Nafis

    Thanks for these great videos, Bob. But I am stuck in something. I have animated the reelgrid. Now I want to rotate the circle dynamically. You have given the "To" property of the storyboard "360". I want it will change after every click. For example, at first click 360, 2nd click 150, 3rd click 270 etc..... how could I get this??

  • User profile image
    kukuom

    private void Delete_Click(object sender, RoutedEventArgs e)
    {
    MessageBoxResult message = MessageBox.Show("This Sound will be deleted permanent.", "Delete?", MessageBoxButton.OKCancel);
    if (message == MessageBoxResult.OK)
    {
    using (IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication())
    {
    var selectedSound = (sender as MenuItem).DataContext as SoundData;
    SpeakerLongListSelector.ItemsSource.Remove(selectedSound);

    // Delete selectedSound.FilePath
    if (isoStore.FileExists(selectedSound.FilePath))
    {
    isoStore.DeleteFile(selectedSound.FilePath);

    }

    var data = JsonConvert.SerializeObject(App.ViewModel.CustomSounds);

    IsolatedStorageSettings.ApplicationSettings[SoundModel.CustomSoundKey] = data;
    IsolatedStorageSettings.ApplicationSettings.Save();

    }
    }

    Dear Bob!

    I just try to write down the Delete_Click code to delete item in the LongListSelector. The problem I got is the sound *.wav can not be deleted when click "delete". It just disappear when i quit and reopen the app. So mayb something need to be refresh after deleting item?

     

Add Your 2 Cents