Advertisement
Guest User

Binding Refactored

a guest
Jun 11th, 2022
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.31 KB | None | 0 0
  1. private void Bind()
  2. {
  3.     // Для каждого визуального контрола поищем метод, с которым его надо связать
  4.     for (int i = 0; i < BindingBehavior.Count; i++)
  5.     {
  6.         BindingEvent eventContainer = null;
  7.         var behaviorName = BindingBehavior[i].Name;
  8.        
  9.         if (Related != null && !IsDoneBinding(behaviorName))
  10.         {
  11.             eventContainer = Related.GetBindingEvent(behaviorName);
  12.             AddDoneBinding(behaviorName);
  13.         }
  14.        
  15.         if (eventContainer != null)
  16.         {
  17.             BindEvent(BindingBehavior[i], eventContainer);
  18.         }
  19.     }
  20.    
  21.     if (Related == null)
  22.         return;
  23.    
  24.     // Для каждого метода, поищем визуальный контрол, который не знает как себя вести
  25.     for (int i = 0; i < BindingEvent.Count; i++)
  26.     {
  27.         var eventName = BindingEvent[i].Name;
  28.         if (IsDoneBinding(eventName))
  29.             continue;
  30.        
  31.         BindingBehavior behaviorContainer;
  32.         behaviorContainer = Related.GetBindingBehavior(eventName);
  33.        
  34.         if (behaviorContainer != null)
  35.         {
  36.             BindEvent(behaviorContainer, BindingEvent[i]);
  37.             AddDoneBinding(eventName);
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement