Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <ListView Grid.Column="0"
- Name="listOfRecipes"
- Margin="10,10,10,240"
- Height="150"
- ItemsSource="{Binding Path=Recipe}"
- SelectedItem="{Binding Path=RecipeName, Mode=TwoWay}">
- <ListView.ItemTemplate>
- <DataTemplate>
- <TextBlock Text="{Binding Path=RecipeName, Mode=TwoWay}" /> // This lists my items in the ListView Correctly
- </DataTemplate>
- </ListView.ItemTemplate>
- </ListView>
- <TextBox Text="{Binding Path=RecipeName, Mode=TwoWay}" Grid.Column="1" Height="50" Margin="10,10,-10,340"/> // This doesn't preview the selected item.
- public partial class ViewAll : Page, INotifyPropertyChanged
- {
- private Recipe _recipe;
- public Recipe Recipe
- {
- get { return _recipe; }
- set
- {
- if(_recipe != value)
- {
- _recipe = value;
- OnPropertyChanged("Recipe");
- }
- }
- }
- public ViewAll()
- {
- InitializeComponent();
- LoadItemTemplate();
- }
- public void LoadItemTemplate()
- {
- mrydendbEntities dbe = new mrydendbEntities();
- listOfRecipes.ItemsSource = dbe.Recipe.ToList();
- listOfRecipes.SelectedItem = dbe.Recipe.First();
- }
- public event PropertyChangedEventHandler PropertyChanged;
- private void OnPropertyChanged([CallerMemberName] string propertyName = null)
- {
- PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement