怎么设置panel面板的垂直方向居中呢

怎么设置panel面板的垂直方向居中呢?例如:设置了panel的最小高度,然后panel里的文本向垂直方向上居中怎么设置呢?

this.GraphObject(go.Panel, "Vertical", { 
     defaultAlignment: go.Spot.Center, 
     stretch: go.GraphObject.Fill,
     itemTemplate: this.GraphObject(go.Panel, "Horizontal",
             this.GraphObject(go.TextBlock, textStyle(), {
                   margin: new go.Margin(0, 5, 5, 10), 
                   spacingAbove: 5, 
                   alignment: go.Spot.Center, 
                   verticalAlignment: go.Spot.Center,
                   textAlign: "center" 
                  },
                    new go.Binding("text", "key")),
                  this.GraphObject(go.TextBlock, textStyle(), {margin: new go.Margin(0, 10, 5, 0),spacingAbove: 5,stroke: "#117bfe",verticalAlignment: go.Spot.Center,},
                    new go.Binding("text", "text"))
              )},
              new go.Binding("itemArray", "items"),
                new go.Binding("visible", "", function(nodeData, e){
                  return !!(nodeData.nodetype !== "datasource" && nodeData.status);
                })
              )

Which element in which panel are you asking about?

Thank you for posting your code, but it would help if you made sure it was indented properly.

Sorry, I didn’t describe it clearly. The outermost panel is set to “minSize: new go.Size(NaN, 70)”. How do I make the items inside the panel be centered in the vertical direction? DefaultAlignment can be used in the horizontal direction, but what properties can be achieved in the vertical direction? Looking forward to your reply! Thank you

this.GraphObject(go.Panel, "Vertical",
    {
        defaultAlignment: go.Spot.Center,
        stretch: go.GraphObject.Fill,
        minSize: new go.Size(NaN, 70),
        itemTemplate: this.GraphObject(go.Panel, "Horizontal",
            this.GraphObject(go.TextBlock, textStyle(),
                {
                    margin: new go.Margin(0, 5, 5, 10),
                    spacingAbove: 5,
                    alignment: go.Spot.Center,
                    verticalAlignment: go.Spot.Center,
                    textAlign: "center"
                },
                new go.Binding("text", "key")),
            this.GraphObject(go.TextBlock, textStyle(),
                {
                    margin: new go.Margin(0, 10, 5, 0),
                    spacingAbove: 5,
                    stroke: "#117bfe",
                    verticalAlignment: go.Spot.Center
                },
                new go.Binding("text", "text"))
        )
    },
    new go.Binding("itemArray", "items"),
    new go.Binding("visible", "", function (nodeData, e) {
        return !!(nodeData.nodetype !== "datasource" && nodeData.status);
    })
)

The “Vertical” Panel doesn’t support much flexibility in the vertical positioning of its elements.

One possibility is to wrap another Panel around that Panel, so you can position that inner panel how you like.relative to the outer panel. But you probably are not able to set stretch to Fill on that inner Panel.

Another possibility is to use a “Table” Panel. But I’m not sure what you really want.