<Instance ref.Class="sample::TabWindowTemplate">
  <ref.Members><![CDATA[
    func GetTabHeaderContainer() : GuiGraphicsComposition*
    {
      return self.headerContainer;
    }
    prop TabHeaderContainer : GuiGraphicsComposition* {GetTabHeaderContainer}
  ]]></ref.Members>
  <WindowTemplate ref.Name="self" ContainerComposition-ref="container" MinSizeLimitation="LimitToElementAndChildren">
    <att.CustomFrameEnabled>true</att.CustomFrameEnabled>
    <att.MaximizedBoxOption>AlwaysTrue</att.MaximizedBoxOption>
    <att.MinimizedBoxOption>AlwaysTrue</att.MinimizedBoxOption>
    <att.BorderOption>AlwaysTrue</att.BorderOption>
    <att.SizeBoxOption>AlwaysTrue</att.SizeBoxOption>
    <att.IconVisibleOption>AlwaysTrue</att.IconVisibleOption>
    <att.TitleBarOption>AlwaysTrue</att.TitleBarOption>

    <ev.CustomFramePaddingChanged-eval>
      <![CDATA[
        {
          var margin = self.CustomFramePadding;
          frameTable.SetRowOption(0, {composeType:Absolute absolute:margin.top});
          frameTable.SetRowOption(2, {composeType:Absolute absolute:margin.bottom});
          frameTable.SetColumnOption(0, {composeType:Absolute absolute:margin.left});
          frameTable.SetColumnOption(2, {composeType:Absolute absolute:margin.right});
        }
      ]]>
    </ev.CustomFramePaddingChanged-eval>

    <SolidBackground Color="#2D2D30"/>
    <Bounds AlignmentToParent="left:0 top:0 right:0 bottom:0">
      <SolidBorder>
        <att.Color-bind>
          <![CDATA[
            cast Color let margin = self.CustomFramePadding in (
              (not self.Border) or (margin.left + margin.top + margin.right + margin.bottom == 0) ? "#00000000" :
              self.VisuallyEnabled and self.Activated ? "#017ACC" :
              "#434346"
            )
          ]]>
        </att.Color-bind>
      </SolidBorder>

      <Table ref.Name="frameTable" AlignmentToParent="left:0 top:0 right:0 bottom:0" MinSizeLimitation="LimitToElementAndChildren">
        <att.Rows>
          <CellOption>composeType:Absolute absolute:0</CellOption>
          <CellOption>composeType:Percentage percentage:1.0</CellOption>
          <CellOption>composeType:Absolute absolute:0</CellOption>
        </att.Rows>
        <att.Columns>
          <CellOption>composeType:Absolute absolute:0</CellOption>
          <CellOption>composeType:Percentage percentage:1.0</CellOption>
          <CellOption>composeType:Absolute absolute:0</CellOption>
        </att.Columns>

        <Cell Site="row:0 column:0" AssociatedHitTestResult="BorderLeftTop"/>
        <Cell Site="row:0 column:2" AssociatedHitTestResult="BorderRightTop"/>
        <Cell Site="row:2 column:0" AssociatedHitTestResult="BorderLeftBottom"/>
        <Cell Site="row:2 column:2" AssociatedHitTestResult="BorderRightBottom"/>

        <Cell Site="row:1 column:0" AssociatedHitTestResult="BorderLeft"/>
        <Cell Site="row:1 column:2" AssociatedHitTestResult="BorderRight"/>
        <Cell Site="row:0 column:1" AssociatedHitTestResult="BorderTop"/>
        <Cell Site="row:2 column:1" AssociatedHitTestResult="BorderBottom"/>
      </Table>

      <Table ref.Name="contentTable" AlignmentToParent-bind="self.CustomFramePadding" MinSizeLimitation="LimitToElementAndChildren">
        <att.Rows>
          <CellOption>composeType:MinSize</CellOption>
          <CellOption>composeType:Percentage percentage:1.0</CellOption>
        </att.Rows>
        <att.Columns>
          <CellOption>composeType:MinSize</CellOption>
          <CellOption>composeType:MinSize</CellOption>
          <CellOption>composeType:Percentage percentage:1.0</CellOption>
          <CellOption>composeType:MinSize</CellOption>
          <CellOption>composeType:MinSize</CellOption>
          <CellOption>composeType:MinSize</CellOption>
        </att.Columns>

        <Cell Site="row:0 column:3" AssociatedHitTestResult="ButtonMinimum">
          <Button AutoFocus="false" Text=" 0 " Font="fontFamily:'Webdings' size:16">
            <att.BoundsComposition-set AlignmentToParent="left:1 top:1 right:1 bottom:1"/>
          </Button>
        </Cell>
        <Cell Site="row:0 column:4" AssociatedHitTestResult="ButtonMaximum">
          <Button AutoFocus="false" Text-bind="self.Maximized ? ' 1 ' : ' 2 '" Font="fontFamily:'Webdings' size:16">
            <att.BoundsComposition-set AlignmentToParent="left:1 top:1 right:1 bottom:1"/>
          </Button>
        </Cell>
        <Cell Site="row:0 column:5" AssociatedHitTestResult="ButtonClose">
          <Button AutoFocus="false" Text=" r " Font="fontFamily:'Webdings' size:16">
            <att.BoundsComposition-set AlignmentToParent="left:1 top:1 right:1 bottom:1"/>
          </Button>
        </Cell>

        <Cell Site="row:0 column:0" MinSizeLimitation-bind="(self.Icon is not null ? LimitToElementAndChildren : NoLimit) of (GuiGraphicsComposition::MinSizeLimitation)">
          <Table AlignmentToParent="left:0 top:0 right:2 bottom:0" MinSizeLimitation="LimitToElementAndChildren">
            <att.Rows>
              <CellOption>composeType:Percentage percentage:1.0</CellOption>
              <CellOption>composeType:Absolute absolute:16</CellOption>
              <CellOption>composeType:Percentage percentage:1.0</CellOption>
            </att.Rows>
            <att.Columns>
              <CellOption>composeType:Absolute absolute:16</CellOption>
            </att.Columns>

            <Cell Site="row:1 column:0" AssociatedHitTestResult="Icon">
              <ImageFrame Stretch="true" Image-bind="self.Icon is not null ? self.Icon.Image : null" FrameIndex-bind="self.Icon is not null ? self.Icon.FrameIndex : -1"/>
            </Cell>
          </Table>
        </Cell>
        <Cell Site="row:0 column:1" AssociatedHitTestResult="Title">
          <Bounds AlignmentToParent="left:5 top:5 right:5 bottom:5" MinSizeLimitation="LimitToElementAndChildren">
            <SolidLabel Text-bind="self.Text" Font="fontFamily:'Segoe WP SemiLight' size:14 antialias:true">
              <att.Color-bind>
                <![CDATA[
                  cast Color (
                    self.VisuallyEnabled and self.Activated ? "#999999" :
                    "#6D6D6D"
                  )
                ]]>
              </att.Color-bind>
            </SolidLabel>
          </Bounds>
        </Cell>

        <Cell Site="row:0 column:2" AssociatedHitTestResult="Title">
          <Bounds ref.Name="headerContainer" AlignmentToParent="left:0 top:0 right:0 bottom:0" MinSizeLimitation="LimitToElementAndChildren"/>
        </Cell>
        <Cell Site="row:1 column:0 columnSpan:6" AssociatedHitTestResult="Client">
          <Bounds ref.Name="container" AlignmentToParent="left:0 top:0 right:0 bottom:0" MinSizeLimitation="LimitToElementAndChildren"/>
        </Cell>
      </Table>
    </Bounds>
  </WindowTemplate>
</Instance>