SHARE
TWEET

Untitled

a guest Aug 21st, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <ListView Grid.Column="0"
  2.                   Name="listOfRecipes"
  3.                   Margin="10,10,10,240"
  4.                   Height="150"
  5.                   ItemsSource="{Binding Path=Recipe}"
  6.                   SelectedItem="{Binding Path=RecipeName, Mode=TwoWay}">
  7.             <ListView.ItemTemplate>
  8.                 <DataTemplate>
  9.                     <TextBlock Text="{Binding Path=RecipeName, Mode=TwoWay}"  /> // This lists my items in the ListView Correctly
  10.                 </DataTemplate>
  11.             </ListView.ItemTemplate>
  12.         </ListView>
  13.         <TextBox Text="{Binding Path=RecipeName, Mode=TwoWay}" Grid.Column="1" Height="50" Margin="10,10,-10,340"/> // This doesn't preview the selected item.
  14.      
  15. public partial class ViewAll : Page, INotifyPropertyChanged
  16.     {
  17.         private Recipe _recipe;
  18.         public Recipe Recipe
  19.         {
  20.             get { return _recipe; }
  21.             set
  22.             {
  23.                 if(_recipe != value)
  24.                 {
  25.                     _recipe = value;
  26.                     OnPropertyChanged("Recipe");
  27.                 }
  28.             }
  29.         }
  30.  
  31.         public ViewAll()
  32.         {
  33.             InitializeComponent();
  34.             LoadItemTemplate();
  35.         }
  36.  
  37.         public void LoadItemTemplate()
  38.         {
  39.             mrydendbEntities dbe = new mrydendbEntities();
  40.             listOfRecipes.ItemsSource = dbe.Recipe.ToList();
  41.             listOfRecipes.SelectedItem = dbe.Recipe.First();
  42.  
  43.         }
  44.  
  45.  
  46.         public event PropertyChangedEventHandler PropertyChanged;
  47.         private void OnPropertyChanged([CallerMemberName] string propertyName = null)
  48.         {
  49.             PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
  50.         }
  51.     }
  52. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top