I'm new to WP8 and follow many tutorials. For parts of the menu I use a viewModel with NotifyPropertyChanged. When I get my list of news articles it creates a viewModel and displays it in a longListSelector. But also I want to make 1 HubTile with the image and some preview-text of the first article. Is there a nice way to send some event to the .xaml.cs? Or do I have to make another viewModel for this one HubTile and make a binding?
Ony try was to make such a variable: private bool _isDataLoaded = false;
public bool IsDataLoaded
{
get
{
return _isDataLoaded;
}
set
{
if (value != _isDataLoaded)
{
_isDataLoaded = value;
NotifyPropertyChanged("IsDataLoaded");
}
}
}
The same thing is used with "IsLoading"-variable to create a loading-indicator in the systemTray:
void MainPage_Loaded(object sender, RoutedEventArgs e)
{
System.Diagnostics.Debug.WriteLine("MainPage_Loaded-Funktion");
Binding binding = new Binding("IsLoading") { Source = DataContext };
BindingOperations.SetBinding(
prog, ProgressIndicator.IsVisibleProperty, binding);
binding = new Binding("IsLoading") { Source = DataContext };
BindingOperations.SetBinding(
prog, ProgressIndicator.IsIndeterminateProperty, binding);
prog.Text = "Lade aktuelle Inhalte...";
}
Can I use this to call a function, when my variable is set and I get a notification?
IsDataLoaded. And you can bind to an array item with the following syntax{Binding Items[0]}. - Toni Petrina<phone:LongListSelector ItemSource="{Binding OnlineNews}"> <TextBlock Text="{Binding TeaserText}"/> </phone:LongListSelector>.First I tell the compiler which Model: "OnlineNews" and then I say which Value of Element x for the x'th row. In my case with the HubTile I tried<toolkit:HubTile Message="{Binding OnlineNews[0].TeaserText}"/>It doesn't crash but also doesn't do anything else :( // You're free to post a "big" comment. Otherwise I can't check your answer as valid solution ;) - ecth