Making Viewport2D.Domain a DP

Jan 27, 2010 at 11:45 PM

I have been struggling to set the domain on my plotter.  I load many different datasets, and they have different values so I cannot use a fixed Domain.

Ideally, since with FitToView the Visible rect size is already calculated it would be wonderful to have a 'LockAtMax' property- which basically sets the Domain to the fitted to view rect.  This would prevent scrolling out and panning out to where there is no data.

But short of this, if I have to calculate my own Domain rect based on my data, can Domain be made a dependency property so I can bind it?  As it stands, it is only useful if you hardcode the values in.

Or, if there is another way to lock the scrolling and zoom out please let me know!


Feb 4, 2010 at 6:57 PM


you can inherit MouseNavigation class and override ShouldStartPanning and ShouldStartZoom to check your conditions. You must remove default MouseNavigation and Add your implementation of this class.


Jefferson Soares


Jun 16, 2010 at 7:02 PM

I would like to make Viewport2D.Domain a dependency property so I can bind my DataRect to it in Xaml with something like this:

<d3:ChartPlotter x:Name="chartPlotterCandela" Margin="5,15,5,5" MinWidth="600" MinHeight="600" Domain="{Binding MyViewportDomain, UpdateSourceTrigger=PropertyChanged}">


How can I make this happen?

Jun 20, 2010 at 2:18 PM

Domain property of ChartPlotter.Viewport is now a dependency property.


Code is uploaded here:


Jun 23, 2010 at 4:37 PM

This works great, however you can only set the binding in the code behind. I have yet to find a way to set the binding in xaml. How can you access the Domain in xaml? Here is my xaml snippet. I would like to say this somewhere: Domain="{Binding MyCustomDomain}", however I cannot figure out where to do so.

<!-- CandelaColorChart -->
<d3:ChartPlotter x:Name="chartPlotterCandela" Margin="5,15,5,5" MinWidth="600" MaxWidth="750" MinHeight="600">
    <d3:Header TextBlock.FontSize="18" Content="{Binding ChartHeader}" VerticalAlignment="Top" Margin="5"  FontFamily="Arial" FontSize="16"/>
    <d3:HorizontalAxisTitle x:Name="horizontalAxisTitleCandela" Content="Horizontal Angle" FontSize="11" Margin="5"/>
    <d3:VerticalAxisTitle x:Name="verticalAxisTitleCandela" Content="Vertical Angle" FontSize="11" Margin="5"/>
        <Image x:Name="imageCandela" Stretch="Fill" Source="{Binding CandelaBitmapSource}"/>
    <d3:DraggablePoint x:Name="draggablePointCandela" Position="0.5,0.5" PositionChanged="draggablePointCandela_PositionChanged"/>
    <d3:VerticalLine x:Name="verticalLineCandela" Value="{Binding DraggablePointX}" Stroke="Red"/>
    <d3:HorizontalLine x:Name="horizontalLineCandela" Value="{Binding DraggablePointY}" Stroke="Red"/>
    <d3:CursorCoordinateGraph />
<!-- END CandelaColorChart -->


Jul 6, 2010 at 7:07 AM

Add a new DependencyProperty of "Domain" to Plotter2D to facilitate the binding:

/// Gets or sets the domain - rectangle in viewport coordinates that limits maximal size of  rectangle.
/// The domain.
public DataRect Domain
    get { return (DataRect)GetValue(DomainProperty); }
    set { SetValue(DomainProperty, value); }

/// The Domain dependency property
public static readonly DependencyProperty DomainProperty = DependencyProperty.Register(
  new FrameworkPropertyMetadata(DataRect.Empty, OnDomainReplaced));

private static void OnDomainReplaced(DependencyObject d, DependencyPropertyChangedEventArgs e)
    Plotter2D owner = (Plotter2D)d;
    if (owner != null)

private void OnDomainChanged(DataRect rect)
    viewport.Domain = rect;