Skip to content

Commit

Permalink
ContId property in LyoutContent is a dependency property
Browse files Browse the repository at this point in the history
  • Loading branch information
Dirkster99 committed Oct 7, 2019
1 parent 37109e1 commit 9fa76a7
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 17 deletions.
46 changes: 31 additions & 15 deletions source/Components/Xceed.Wpf.AvalonDock/Layout/LayoutContent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ This program is provided to you under the terms of the Microsoft Public
using System.Windows.Media;
using System.ComponentModel;


namespace Xceed.Wpf.AvalonDock.Layout
{
[ContentProperty( "Content" )]
Expand Down Expand Up @@ -89,38 +90,53 @@ public object Content
RaisePropertyChanging( "Content" );
_content = value;
RaisePropertyChanged( "Content" );

if( this.ContentId == null )
{
var contentAsControl = _content as FrameworkElement;
if( contentAsControl != null && !string.IsNullOrWhiteSpace( contentAsControl.Name ) )
{
this.SetCurrentValue( LayoutContent.ContentIdProperty, contentAsControl.Name );
}
}
}
}
}

#endregion

#region ContentId

private string _contentId = null;
public static readonly DependencyProperty ContentIdProperty = DependencyProperty.Register( "ContentId", typeof( string ), typeof( LayoutContent ), new UIPropertyMetadata( null, OnContentIdPropertyChanged ) );

public string ContentId
{
get
{
if( _contentId == null )
{
var contentAsControl = _content as FrameworkElement;
if( contentAsControl != null && !string.IsNullOrWhiteSpace( contentAsControl.Name ) )
return contentAsControl.Name;
}
return _contentId;
return (string)GetValue( ContentIdProperty );
}
set
{
if( _contentId != value )
{
_contentId = value;
RaisePropertyChanged( "ContentId" );
}
SetValue( ContentIdProperty, value );
}
}

#endregion
private static void OnContentIdPropertyChanged( DependencyObject obj, DependencyPropertyChangedEventArgs args )
{
var layoutContent = obj as LayoutContent;
if( layoutContent != null )
{
layoutContent.OnContentIdPropertyChanged( (string)args.OldValue, (string)args.NewValue );
}
}

private void OnContentIdPropertyChanged( string oldValue, string newValue )
{
if( oldValue != newValue )
{
this.RaisePropertyChanged( "ContentId" );
}
}
#endregion ContentId

#region IsSelected

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
<Authors>https://github.com/Dirkster99/AvalonDock</Authors>
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|netcoreapp3.0|AnyCPU'">
<DefineConstants />
</PropertyGroup>

<ItemGroup>
<Resource Include="**\*.png" />
Expand All @@ -28,4 +31,8 @@
<ItemGroup>
<None Include="LICENSE.txt" Pack="true" PackagePath="" />
</ItemGroup>

<!--PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DefineConstants>TRACE;DEBUG</DefineConstants>
</PropertyGroup>-->
</Project>
31 changes: 29 additions & 2 deletions source/MLibTest/MLibTest/MLibTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,30 @@
<WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<TargetFrameworkProfile />
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG</DefineConstants>
<DefineConstants>
</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
Expand Down Expand Up @@ -204,6 +220,17 @@
<ItemGroup>
<Resource Include="Demos\Images\property-blue.png" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.5.2">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.5.2 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

0 comments on commit 9fa76a7

Please sign in to comment.