2020年12月31日星期四

Combobox passed as a Control template then as a popup

I have a combobox "recent_users" as a control template and then as a poppup. How can I pass the selected value of the popup to the method below?(popup click)

recent_users.SelectedItem.ToString() always returns null.

    private void usernameEnter_PreviewMouseUp(object sender, MouseButtonEventArgs e)      {          Trace.WriteLine("testing dropdown");          ControlTemplate ct = recent_users.Template;          Popup popup1 = ct.FindName("PART_Popup", recent_users) as Popup;            if (popup1 != null)          {              popup1.Placement = PlacementMode.Top;          }                    recent_users.IsDropDownOpen = true;          popup1.PreviewMouseUp += new MouseButtonEventHandler((s,e) => popupClick(s,e,recent_users.SelectedItem.ToString()));      }        private void popupClick(object sender, MouseButtonEventArgs e, String recent)      {          usernameEnter.Text = recent;          Trace.WriteLine("appending norms");      }  }  

}

https://stackoverflow.com/questions/65526121/combobox-passed-as-a-control-template-then-as-a-popup January 01, 2021 at 06:55AM

没有评论:

发表评论