WP7 databinding displays int but not string?

Posted by user1794106 on Stack Overflow See other posts from Stack Overflow or by user1794106
Published on 2012-11-04T04:56:36Z Indexed on 2012/11/04 5:00 UTC
Read the original article Hit count: 200

Whenever I test my app.. it binds the data from Note class and displays it if it isn't a string. But for the string variables it wont bind. What am I doing wrong?

Inside my main:

    <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
        <ListBox x:Name="Listbox" SelectionChanged="listbox_SelectionChanged" ItemsSource="{Binding}">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Border Width="800" MinHeight="60">
                        <StackPanel>
                            <TextBlock x:Name="Title" VerticalAlignment="Center" FontSize="{Binding TextSize}"  Text="{Binding Name}"/>
                            <TextBlock x:Name="Date"  VerticalAlignment="Center" FontSize="{Binding TextSize}"  Text="{Binding Modified}"/>
                        </StackPanel>
                    </Border>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
    </Grid>
</Grid>

in code behind:

    protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
    {
        MessageBox.Show("enters onNav Main");
        DataContext = null;
        DataContext = Settings.NotesList;


        Settings.CurrentNoteIndex = -1;
        Listbox.SelectedIndex = -1;


        if (Settings.NotesList != null)
        {
            if (Settings.NotesList.Count == 0)
            {
                Notes.Text = "No Notes";
            }
            else
            {
                Notes.Text = "";
            }
        }
    }

and

 public static class Settings
 {
    public static ObservableCollection<Note> NotesList;
    static IsolatedStorageSettings settings;
    private static int currentNoteIndex;

    static Settings()
    {
        NotesList = new ObservableCollection<Note>();
        settings = IsolatedStorageSettings.ApplicationSettings;
        MessageBox.Show("enters constructor settings");
    }

notes class:

public class Note
{

    public DateTimeOffset Modified { get; set; }
    public string Title { get; set; }
    public string Content { get; set; }
    public int TextSize { get; set; }

public Note()
{
    MessageBox.Show("enters Note Constructor");
    Modified = DateTimeOffset.Now;
    Title = "test";
    Content = "test";
    TextSize = 32;
} 

}

© Stack Overflow or respective owner

Related posts about windows-phone-7

Related posts about data-binding