public CustomComboBox() { Loaded += (sender, e) => { //设置DisplayMemberPath、SelectedValuePath DisplayMemberPath = CustomDisplayMemberPath; SelectedValuePath = CustomSelectedValuePath; //设置值为默认双向绑定 SetBindingModeToTwoWay(); CustomNotificationMessenger.Register <string>(this, NotificationMessageToken.CloseComboBoxItemArea, message => { //页面滚动条滚动时自动关闭打开的ComboBox下拉项 IsDropDownOpen = false; }); }; Unloaded += (sender, e) => { CustomNotificationMessenger.Unregister <string>(this); }; SelectionChanged += CustomComboBox_SelectionChanged; }
protected void UnregisterMessages() { CustomNotificationMessenger.Unregister <string>(this); }