views:

11

answers:

1

I defined the following layout:

<Grid Name="RootGrid" Background="{StaticResource WindowBackground}" >
        <s:ScatterView Name="RootScatter">
            <Viewbox>
                <s:LibraryContainer Name="RootContainer" Grid.Row="0" ViewingMode="Bar">
                    <s:LibraryContainer.BarView>
                        <s:BarView Rows="2" NormalizedTransitionSize="2.5,0.8" ItemTemplate="{StaticResource ContainerItemTemplate}">
                        </s:BarView>
                    </s:LibraryContainer.BarView>
                    <s:LibraryContainer.StackView>
                        <s:StackView NormalizedTransitionSize="1,1" ItemTemplate="{StaticResource ContainerItemTemplate}">
                        </s:StackView>
                    </s:LibraryContainer.StackView>
                </s:LibraryContainer>
            </Viewbox>
        </s:ScatterView>
        <s:ScatterView Name="ClassScatter"></s:ScatterView>
    </Grid>
</s:SurfaceWindow>

Now I add dynamically Item to the second ScatterView:

public void expand(SurfaceWindow1 surfaceWindow)
        {
            Logging.Logger.getInstance().log("Expand class " + name);

            if (!isExpanded())
            {
                Viewbox vb = new Viewbox();
                SurfaceTextBox txt = new SurfaceTextBox();
                txt.Text = this.name + "\nLOC: " + this.getLoc() + "\nFanIn: " + this.getFanIn() + "\nFanOut: " + this.getFanOut() + "\nComplexity: " + this.getComplexity();
                txt.IsReadOnly = true;

                vb.Child = txt;
                surfaceWindow.ClassScatter.Items.Add(vb);
                this.setExpanded(true);
            }
        }

This works great, but unfortunately, I can't changed the size, move, or rotate the object that is created. Any hints why?

+1  A: 

The problem is that your TextBox captures the touch contacts and the ScatterView can't capture them for dragging/zooming/rotating the TextBox. There are two options to solve your problem:

  1. If you want the item to be movable but not editable by the user, replace the SurfaceTextBox with a regular TextBlock
  2. If you still want the text to be editable, add some margins to your TextBox to create a "dragging zone" around the element. E.g.: txt.Margin = new Thickness(20);
robertos
Thanks your hint worked like a charm!
Roflcoptr