def _create_button(self, content, callback): if content: button = Button() button.Margin = Thickness(10) button.MaxHeight = 50 button.MaxWidth = 150 button.SetValue(Grid.RowProperty, 2) button.Content = content button.Click += callback return button
def _bind_esc_to_close_dialog(self): # There doesn't seem to be easy way to bind esc otherwise than having # a cancel button that binds it automatically. We don't always have # actual cancel button so need to create one and make it invisible. # Cannot actually hide it because it won't work after that so we just # make it so small it is not seen. button = Button() button.IsCancel = True button.MaxHeight = 1 button.MaxWidth = 1 self.Content.AddChild(button)