Hello Actipro,
I'm currently trying before buy the WPF suite and have a question regarding serialization. (I searched the forum but found nothing that could help me)
<DataTemplate x:Key="DockingWindowContentDataTemplate">
<ContentPresenter Content="{Binding View}"/>
</DataTemplate>
<Style x:Key="DockingWindowStyle" TargetType="docking:DockingWindow">
<!--<Setter Property="Description" Value="{Binding Path=Description, Mode=TwoWay}" />-->
<Setter Property="ImageSource" Value="{Binding Path=Icon, Converter={StaticResource ImageSourceConverter}, Mode=TwoWay}" />
<Setter Property="IsActive" Value="{Binding Path=ViewModel.IsActive, Mode=TwoWay}" />
<Setter Property="IsOpen" Value="{Binding Path=ViewModel.IsOpen, Mode=TwoWay}" />
<Setter Property="IsSelected" Value="{Binding Path=ViewModel.IsSelected, Mode=TwoWay}" />
<Setter Property="SerializationId" Value="{Binding Path=Id, Mode=TwoWay}" />
<Setter Property="Title" Value="{Binding Path=ViewModel.Title, Mode=TwoWay}" />
<Setter Property="WindowGroupName" Value="{Binding Path=ViewModel.WindowGroupName, Mode=TwoWay}" />
</Style>
<Style x:Key="ToolWindowStyle" TargetType="docking:ToolWindow" BasedOn="{StaticResource DockingWindowStyle}">
<Setter Property="DefaultDockSide" Value="{Binding Path=ViewModel.DockSide, Mode=TwoWay, Converter={StaticResource ToolItemDockSideConverter}}" />
<Setter Property="State" Value="{Binding Path=ViewModel.PositionState, Mode=TwoWay, Converter={StaticResource ToolItemStateConverter}}" />
</Style>
With docksite:
<docking:DockSite x:Name="DockSite" DocumentItemTemplate="{StaticResource DockingWindowContentDataTemplate}"
DocumentItemContainerStyle="{StaticResource DockingWindowStyle}"
ToolItemContainerStyle="{StaticResource ToolWindowStyle}"
ToolItemTemplate="{StaticResource DockingWindowContentDataTemplate}"
DockPanel.Dock="Top" MdiKind="Standard" DocumentItemsSource="{Binding Documents}" ToolItemsSource="{Binding Tools}">
<docking:SplitContainer>
<docking:Workspace>
<docking:StandardMdiHost />
</docking:Workspace>
<docking:ToolWindowContainer />
</docking:SplitContainer>
</docking:DockSite>
In my DataContext I add Documents and Tools and all works fine.
How I can do deserilization and resolve (via ioc container) view model types (i have also unique serializationId for each tools/documents) ?
I also try to assign Context and Content during DockingWindowDeserialization but i lose Style and DataTemplate
var tool = await _windowService.BuildTool(serializedTool.ViewModelType);
tool.Id = serializedTool.Id;
// args.Window.Content = tool.View;
if (tool.ToolType == ToolType.Tool)
{
args.Window.DataContext = tool.ViewModel;
args.Window.Content = tool.View;
args.Window.Title = tool.Title;
await tool.ViewModel.OnShow();
_windowService.Tools.Add(tool);
args.Handled = true;
}
Can you help me? Thank you!
Tommaso
[Modified 3 years ago]