I've been able to transfer objects between pages with ease, but now I can't display the data in the xaml markup.
Here's the Quote entity that's stored in a sdf-file on the application:
[Table]
public class Quote
{
[Column(IsPrimaryKey = true, IsDbGenerated = true, DbType = "INT NOT NULL Identity", CanBeNull = false, AutoSync = AutoSync.OnInsert)]
public int Id { get; set; }
[Column(CanBeNull = false)]
public string QuoteOfTheDay { get; set; }
[Column(CanBeNull = false)]
public string SaidBy { get; set; }
[Column(CanBeNull = true)]
public string Context { get; set; }
[Column(CanBeNull = true)]
public string Episode { get; set; }
[Column(CanBeNull = true)]
public string Season { get; set; }
}
Here's the code behind:
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
DataContext = this;
var quote = PhoneApplicationService.Current.State["q"];
Quote quoteToDisplay = (Quote)quote;
}
public static readonly DependencyProperty QuoteToDisplayProperty = DependencyProperty.Register(
"QuoteToDisplay", typeof(Quote), typeof(PhoneApplicationPage), new PropertyMetadata(default(Quote)));
public Quote QuouteToDisplay
{
get { return (Quote)GetValue(QuoteToDisplayProperty); }
set { SetValue(QuoteToDisplayProperty, value); }
}
The xaml:
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<TextBlock FontSize="36" FontFamily="Verdana" FontWeight="ExtraBlack" Text="{Binding QuoteToDisplay.QuoteOfTheDay}" />
</Grid>
I got the exact data that I want to display in the xaml. I want to display the QuoteOfTheDay property in the TextBlock. But everytime I try to use {Binding}, the TextBlock is always empty. When I also try to use Binding, intellisense doesn't suggest "QuoteOfTheDay".
I've obviuosly missed something important, but I can't really see what it is.
Why do you use {Binding} if you assign .Text property in code-behind ? I think you you must remove binding from xaml or (and it's better way) use MVVM.