xceedsoftware/wpftoolkit

DockingManager.ActiveContent binding doesn't work

fasttester opened this issue · 4 comments

Binding from ActiveContent in XAML

(Xceed.Wpf.AvalonDock.DockingManager, ActiveContent="{Binding SelectedContent, Converter={StaticResource ActiveDocumentConverter}, Mode=TwoWay}" )

it doesn't work(does not trigger) in the new version 4.5.22477.12540 (Xceed.Products.Wpf.Toolkit.Full)

in kombination with CommunityToolkit.Mvvm 8.1.0.

But in older versions_( for example version 4.1.21122.16390)_ it worked.

Hi,
Could you submit a sample so we could teste the same scenario as you ? What exactly is your SelectedContent you are trying to bind to ?
Was this an issue in other versions ? v4.2, v4.3 or v4.4 ?
Thank you

hi XceedBoucherS,

thanks for your reply,
the problem with binnding appeared only in the new version (Xceed.Products.Wpf.Toolkit.Full 4.5.22477.12540), in version 4.4.22258.9000 (and all earlier versions)everything was still fine.

Binding between:
MainWindow.xaml

...ActiveContent="{Binding SelectedContent...

and

MainWindowViewModel.cs:

_....
public object SelectedContent
{
get { return _selectedContent; }
set
{
if (selectedContent != value)
....

it doesn't work anymore.
When selecting a new context (windows or tabs), the property will not be affected, as if the binding no longer exists.
The behavior is the same with every code we tried but if no one else has the same problem i can send you my test code.

Hi,

Thank you for your sample. It was much easier to test your scenario.

v4.5 included a fix to prevent a bug happening on the click of a TabItem. We could receive 2 indexes instead of only the wanted one.
Basically, the ActiveContent now returns the LayoutContent instead of the LayoutContent.Content.

Here's your workaround:
Try using your ActiveDocumentConverter this way:
`public object Convert(object value, Type targetType, object parameter,
System.Globalization.CultureInfo culture)
{
if( value == null )
return value;

  var layoutContent = value as LayoutContent;
  if( ( layoutContent != null ) 
			&& (( layoutContent.Content is DockWindowViewModel ) || ( layoutContent.Content == null ) ) )
    return value;
  //if (value is DockWindowViewModel|| value == null)
  //	return value;

  return Binding.DoNothing;
	}

	public object ConvertBack(object value, Type targetType, object parameter,
														System.Globalization.CultureInfo culture)
	{
  if( value == null )
    return value;

  var layoutContent = value as LayoutContent;
		if( ( layoutContent != null )
			&& (( layoutContent.Content is DockWindowViewModel ) || ( layoutContent.Content == null ) ) )
			return value;
		//if (value is DockWindowViewModel || value == null)
		//	return value;

		return Binding.DoNothing;
	}`

Thank you