"> ">

Presentation is loading. Please wait.

Presentation is loading. Please wait.

WinRT Apps 23.10.2014.. <TextBlock x:Name="DirectionsTextBlock" TextWrapping="Wrap" Margin="12,0,0,0" Text="{Binding Directions}" /> <Page…

Similar presentations


Presentation on theme: "WinRT Apps 23.10.2014.. <TextBlock x:Name="DirectionsTextBlock" TextWrapping="Wrap" Margin="12,0,0,0" Text="{Binding Directions}" /> <Page…"— Presentation transcript:

1 WinRT Apps 23.10.2014.

2

3

4

5

6

7 <TextBlock x:Name="DirectionsTextBlock" TextWrapping="Wrap" Margin="12,0,0,0" Text="{Binding Directions}" /> <Page… … DataContext="{Binding Source={StaticResource Locator}, Path=Main}" />

8 <TextBlock x:Name="DirectionsTextBlock" TextWrapping="Wrap" Margin="12,0,0,0" Text="{Binding Directions, Mode=OneWay}" />

9 public class ItemViewModel : INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; … }

10 Subscribes to

11 public class ItemViewModel : INotifyPropertyChanged { private string _id; /// Sample ViewModel property; public string ID { get { return _id; } set { if (value != _id) { _id = value; NotifyPropertyChanged("ID"); } } } public event PropertyChangedEventHandler PropertyChanged; private void NotifyPropertyChanged(String propertyName) { PropertyChangedEventHandler handler = PropertyChanged; if (null != handler) handler(this, new PropertyChangedEventArgs(propertyName)); }

12 public class ItemViewModel : INotifyPropertyChanged { // Properties private string _id; public string ID { get { return _id; } set { this.SetProperty(ref this._id, value); } } // Property Change logic public event PropertyChangedEventHandler PropertyChanged; protected bool SetProperty (ref T storage, T value, [CallerMemberName] String propertyName = null) { if (object.Equals(storage, value)) return false; storage = value; this.OnPropertyChanged(propertyName); return true; } protected void OnPropertyChanged([CallerMemberName] string propertyName = null) { var eventHandler = this.PropertyChanged; if (eventHandler != null) eventHandler(this, new PropertyChangedEventArgs(propertyName)); }

13 ItemsSource="{Binding Ingredients}"/>

14 public class RecipeDetails : INotifyPropertyChanged { /// /// A collection for ItemViewModel objects. /// public ObservableCollection Items { get; private set; } public void LoadData() { this.Items.Add(new ItemViewModel() { ID = "0", LineOne = "runtime one", LineTwo =... }); this.Items.Add(new ItemViewModel() { ID = "1", LineOne = "runtime two", LineTwo =... }); this.Items.Add(new ItemViewModel() { ID = "2", LineOne = "runtime three", LineTwo =...}); }... }

15 <Button Content="{Binding Path=NextItem, Mode=OneWay, TargetNullValue={Binding Path=NullValue}}" /> <TextBlock Text="{Binding Path=badPath, FallbackValue='this is a fallback value'}" Grid.Column="1">

16

17

18

19

20

21


Download ppt "WinRT Apps 23.10.2014.. <TextBlock x:Name="DirectionsTextBlock" TextWrapping="Wrap" Margin="12,0,0,0" Text="{Binding Directions}" /> <Page…"

Similar presentations


Ads by Google