Skip to content

VirtualCanvas Module

Mark Kromis edited this page Oct 20, 2019 · 4 revisions

What does it do

This handles objects that get created when in view and destroyed when leaving view.

Screenshot - VirtualCanvas MesDocument

Supported Platforms

  • WPF (Framework)

Modules Used

Main Services Provided

  • IMesAutoScroll -- Platform scrolling support.
  • IMesContentCanvas -- Platform canvas control.
  • IMesMapZoom -- Platform zooming control.
  • IMesPan -- Platform panning control.
  • IMesRectangleSelectionGesture -- Platform rectangle UI drawing.
  • IMesVirtualCanvas -- The main interface that controls the CanvasControl. This can be used in netstandard space.
  • IMesVirtualCanvasControl -- Interface to the UI control, use platform namespace for control (ie. Graph)
  • IMesVirtualChild -- Platform interface to child to create necessary visuals

Main Usage

This happens in 2 basic parts

Create a view model that inherits from IMesVirtualCanvas. This should handle all necessary adding items to the Graph.VirtualChildren. If using the split method, the IVirtualChild may need to created in platform module and injected into the core classes.

The demo also inherits from MesDocument : IMesVirtualCanvas as a single control document.

The second part handles the UI control. For this example we are using a WPF object. Add a reference to the namespace and embed the object.

<mvx:MvxWpfView 
    ...
    xmlns:ui="clr-namespace:MinoriEditorShell.VirtualCanvas.Platforms.Wpf.Controls;assembly=MinoriEditorShell.VirtualCanvas"
    xmlns:mvx="clr-namespace:MvvmCross.Platforms.Wpf.Views;assembly=MvvmCross.Platforms.Wpf"
    ...>
    <ScrollViewer
        HorizontalScrollBarVisibility="Auto" 
        VerticalScrollBarVisibility="Auto" 
        CanContentScroll="True">
        <ui:MesVirtualCanvas x:Name="Graph" />
    </ScrollViewer>
</mvx:MvxWpfView>

Then add the code behind.

            DataContextChanged += (s, e) =>
            {
                IMesVirtualCanvas dc = (IMesVirtualCanvas)DataContext;
                Graph.UseDefaultControls(dc);
            };

Acknowledgements

Clone this wiki locally