Skip to content

Commit

Permalink
Merge pull request #84 from scdmitryvodich/LayoutDocumentDisappears
Browse files Browse the repository at this point in the history
Fixed issue #83 with LayoutDocument disappearance
  • Loading branch information
Dirkster99 authored Oct 26, 2019
2 parents 380379b + 0e98301 commit fb9ab55
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions source/Components/Xceed.Wpf.AvalonDock/Layout/LayoutContent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,7 @@ public object Content

if( this.ContentId == null )
{
var contentAsControl = _content as FrameworkElement;
if( contentAsControl != null && !string.IsNullOrWhiteSpace( contentAsControl.Name ) )
{
this.SetCurrentValue( LayoutContent.ContentIdProperty, contentAsControl.Name );
}
SetContentIdFromContent();
}
}
}
Expand All @@ -112,7 +108,13 @@ public string ContentId
{
get
{
return (string)GetValue( ContentIdProperty );
string value = (string)GetValue(ContentIdProperty);
if (!string.IsNullOrWhiteSpace(value)) return value;

// #83 - if Content.Name is empty at setting content and will be set later, ContentId will stay null.
SetContentIdFromContent();

return (string)GetValue(ContentIdProperty);
}
set
{
Expand All @@ -136,6 +138,16 @@ private void OnContentIdPropertyChanged( string oldValue, string newValue )
this.RaisePropertyChanged( "ContentId" );
}
}

private void SetContentIdFromContent()
{
var contentAsControl = _content as FrameworkElement;
if (!string.IsNullOrWhiteSpace(contentAsControl?.Name))
{
this.SetCurrentValue(LayoutContent.ContentIdProperty, contentAsControl.Name);
}
}

#endregion ContentId

#region IsSelected
Expand Down

0 comments on commit fb9ab55

Please sign in to comment.