Auto move Nodes

Hi,
I have the following node template:

<DataTemplate x:Key="SimpleButtonTemplate" DataType="{x:Type classes:Element}">
    <Grid go:Part.Resizable="{Binding Path=Part.Diagram.DataContext.EditMode}"
            go:Part.SelectionAdorned="False"
            go:Node.ZOrder="{Binding Path=Data.Z}"
            go:Part.Movable="{Binding Path=Data.IsPinned, Converter={StaticResource BooleanNegationConverter}}"
            go:Part.Selectable="{Binding Path=Data.IsPinned, Converter={StaticResource BooleanNegationConverter}}"
            Width="{Binding Path=Data.Width, Mode=TwoWay}"
            Height="{Binding Path=Data.Height, Mode=TwoWay}"
            Visibility="{Binding Path=Data.Visibility}"
            Background="Transparent">
        <go:Node.Location>
            <MultiBinding Converter="{StaticResource PosToPointConverter}" Mode="TwoWay">
                <Binding Path="Data.X" Mode="TwoWay" />
                <Binding Path="Data.Y" Mode="TwoWay" />
            </MultiBinding>
        </go:Node.Location>

        <Button x:Name="button" Style="{StaticResource KeyboardButtonStyle}"
                Visibility="{Binding Path=Data.NoDisplay, Converter={StaticResource BooleanToVisibilityConverterInverse}}"
                IsHitTestVisible="{Binding Path=Part.Diagram.DataContext.EditMode, Converter={StaticResource BooleanNegationConverter}}"
                Background="{Binding Path=Data.BackgroundBrush}" BorderBrush="{Binding Path=Data.BorderBrush}"
                Foreground="{Binding Path=Data.ForegroundBrush}"
                Content="{Binding Path=Data.Text}" Padding="2"
                FontSize="{Binding Path=Data.FontSize, Converter={StaticResource FontSizePtConverter}, TargetNullValue=12.0}"
                FontFamily="{Binding Path=Data.FontFamily, TargetNullValue=Segoe}" />
        <Grid Visibility="{Binding Path=Data.NoDisplay, Converter={StaticResource BooleanToVisibilityConverter}}"
                Opacity="{StaticResource StandardOpacity}">
            <Path Data="M 0,0 L 0,1 1,1 1,0 0,0 1,1 M 0,1 L 1,0" Stretch="Fill" Stroke="Black" Fill="White" StrokeThickness="1" />
        </Grid>

<!--   This ToggleButton makes a problem -->
        <ToggleButton Width="16" Height="16"/>


    </Grid>
</DataTemplate>

Now, if I zoomed in and pan so that I don’t see the complete Node but I can see the ToggleButton, when I click on the ToggleButton the Node moves so his left border is visible. In the real code there is a command bound to the togglebutton which is not fired then. I didn’t want that behavior, I want my command is fired not depending on how much of the node is in view.

What can I do?

I think you are talking about behavior that all controls have in WPF scrollviews – nothing to do with GoXam in particular.

This post might help: http://stackoverflow.com/questions/8384237/stop-wpf-scrollviewer-automatically-scrolling-to-perceived-content

That will be the problem.
Is there a way to change it?

That StackOverflow topic gave a solution. But I cannot vouch for it, because I have not tried it.

As you surely remember I use a CustomDiagramPanel:

    public class CustomDiagramPanel : DiagramPanel
{
    protected override Rect ComputeDiagramBounds()
    {
        var r = base.ComputeDiagramBounds();
        // always include the current viewport position
        var loc = ViewportBounds.Location;
        loc.X += Padding.Left;
        loc.Y += Padding.Top;
        r.Union(loc);
        return r;
    }
}

with the following use in Xaml:

<go:Diagram x:Name="MainDiagram" NodesSource="{Binding PilotObjectList}"
        NodeTemplateDictionary="{StaticResource NodeTemplates}"
        VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch"
        InitialScale="1.0"
        InitialPosition="0 0"
        GridSnapCellSize="5 5">
    <Control.Template>
        <ControlTemplate TargetType="go:Diagram">
            <Border x:Name="Border"
                    Background="{TemplateBinding Background}"
                    BorderBrush="{TemplateBinding BorderBrush}"
                    BorderThickness="{TemplateBinding BorderThickness}">
                <ScrollViewer HorizontalScrollBarVisibility="Auto"
                                VerticalScrollBarVisibility="Auto"
                                CanContentScroll="True">
                    <diagramManager:CustomDiagramPanel x:Name="Panel"
                                                        Stretch="{TemplateBinding Stretch}"
                                                        Padding="{TemplateBinding Padding}"
                                                        HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                        VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" />
                </ScrollViewer>
            </Border>
        </ControlTemplate>
    </Control.Template>
</go:Diagram>

No I tried to use the RequestIntoView Event on the ScrollViewer and set e.Handled = true;, but there is no change in the behavior.

Any Idea?

Really? It worked well for me:

      myDiagram.TemplateApplied += (snd, evt) => {
        myDiagram.Panel.RequestBringIntoView += (s,e) => { e.Handled = true; }; 
      };

I tried it in xaml in the ScrollViewer:

<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto"                           CanContentScroll="True"  RequestBringIntoView="ScrollViewer_RequestBringIntoView">

private void ScrollViewer_RequestBringIntoView(object sender, System.Windows.RequestBringIntoViewEventArgs e)
{
    e.Handled = true;
}

and this didn’t work!

Anyway, thank you for your post.
I do not know what I would do without your excellent support.

If you read that StackOverflow answer, they put the event handler on their Slider (or whatever it was), not on the ScrollViewer.