Das Verhalten ist korrekt, wenn es aufgeklappt ist.
Wenn ich den GridSplitter verwende, bleibt das linke Bedienfeld im minimierten Zustand bei 0 Pixel, aber ich möchte, dass es der vom GridSplitter vorgenommenen Größenänderung folgt.
Wie man es erreicht das?
Es scheint, dass ich die Ereignisse des GridSplitter nutzen könnte, aber welches und wie? Ziehen* Maus*?
Ich habe eine Benutzersteuerung:
Code: Select all
👁
Code: Select all
public partial class Repro : INotifyPropertyChanged
{
private ICommand? _switchVisibilityCommand;
private Visibility _panelVisibility = Visibility.Visible;
private GridLength _videoPanelWidth;
private GridLength _propPanelWidth;
public Repro()
{
InitializeComponent();
}
public ICommand SwitchVisibilityCommand => _switchVisibilityCommand ?? (_switchVisibilityCommand =
new DelegateCommandListen(
s =>
{
PanelVisibility = PanelVisibility == Visibility.Visible ? Visibility.Collapsed : Visibility.Visible;
if (PanelVisibility == Visibility.Collapsed)
{
_propPanelWidth = ContainerGrid.ColumnDefinitions[0].Width;
_videoPanelWidth = ContainerGrid.ColumnDefinitions[2].Width;
ContainerGrid.ColumnDefinitions[0].Width = new GridLength(0, GridUnitType.Pixel);
ContainerGrid.ColumnDefinitions[2].Width = new GridLength(1, GridUnitType.Star);
}
else
{
ContainerGrid.ColumnDefinitions[2].Width = _videoPanelWidth;
ContainerGrid.ColumnDefinitions[0].Width = _propPanelWidth;
}
},
s => true));
public Visibility PanelVisibility
{
get => _panelVisibility;
set => SetField(ref _panelVisibility, value);
}
#region inpc
public event PropertyChangedEventHandler? PropertyChanged;
protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
protected bool SetField(ref T field, T value, [CallerMemberName] string? propertyName = null)
{
if (EqualityComparer.Default.Equals(field, value)) return false;
field = value;
OnPropertyChanged(propertyName);
return true;
}
#endregion
}