move add button to the right if ok button is not visible

This commit is contained in:
Daniel Schick 2022-10-21 07:41:58 +02:00
parent d52d8b90bb
commit bb5de64cab
2 changed files with 8 additions and 2 deletions

View File

@ -53,7 +53,13 @@ namespace ENI2.Controls
public bool AddVisible
{
get { var addButton = (Button)Template.FindName("buttonAdd", this); return addButton.Visibility == Visibility.Visible; }
set { var addButton = (Button)Template.FindName("buttonAdd", this); addButton.Visibility = value ? Visibility.Visible : Visibility.Hidden; }
set
{
var addButton = (Button)Template.FindName("buttonAdd", this); addButton.Visibility = value ? Visibility.Visible : Visibility.Hidden;
var okButton = (Button)Template.FindName("buttonOK", this);
if (okButton.Visibility == Visibility.Hidden)
okButton.Width = 1; // we are in a DockPanel, try to collapse okButton to place addButton more to the right
}
}
public bool OkVisible

View File

@ -39,8 +39,8 @@ namespace ENI2.EditControls
_data = LocalizedLookup.LoadHAZTemplates();
this.listBoxDescription.ItemsSource = _data;
this.comboBoxType.ItemsSource = Enum.GetValues(typeof(HAZPosTemplate.SublistType));
this.AddVisible = true;
this.OkVisible = false;
this.AddVisible = true;
}
private void comboBoxType_SelectionChanged(object sender, SelectionChangedEventArgs e)