Skip to content

Commit d5ff9ab

Browse files
committed
chore: update window position docs content
1 parent 7d40b42 commit d5ff9ab

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

components/window/position.md

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ The Window offers several ways to control its position:
1414

1515
* [`ContainmentSelector` parameter](#containmentselector)
1616
* [`Top` and `Left` parameters](#top-and-left)
17+
* [Centered Window](#center)
18+
* [Positions Example](#example)
1719

18-
The Window renders [in the root of the application](slug:window-overview#important-notes) or in its [containment element](#containmentselector). If the app is using special CSS positioning, margins, or other offsets on the Window ancestors, these CSS styles may [affect the position of the Window](slug:troubleshooting-general-issues#wrong-popup-position).
20+
The Window renders [in the root of the application](slug:window-overview#important-notes) or in its [containment element](#containmentselector). If the application is using special CSS positioning, margins, or other offsets on the Window ancestors, these CSS styles may [affect the position of the Window](slug:troubleshooting-general-issues#wrong-popup-position). However, if `Top` and `Left` parameters are not defined or equal to `string.Empty`, the Telerik Window will be positioned at the center of the viewport by default.
1921

2022
## ContainmentSelector
2123

@@ -60,11 +62,17 @@ In this case, the Window will render inside the specified container and not as a
6062

6163
## Top and Left
6264

63-
The `Top` and `Left` parameters control the Window placement on the page. The resulting position depends on the whole page content and not on the viewport or the current scroll offset.
65+
The `Top` and `Left` parameters control the Window placement on the page. The resulting position depends on the whole page content and not on the viewport or the current scroll offset. To see the parameters in action, refer to the [example](#example) below.
6466

6567
When the [Window `ContainmentSelector` parameter is set](#containmentselector), the `Top` and `Left` parameters apply with regard to the top-left corner of the containment element.
6668

67-
>caption Using Top and Left to manage the Window position
69+
## Center
70+
71+
The Telerik Window is automatically centered when the `Top` and `Left` parameters are not set or are explicitly set to `string.Empty`. This ensures the Window appears in the middle of the viewport by default. To see this behavior in action, refer to the [example](#example) below.
72+
73+
## Example
74+
75+
>caption Use Top and Left to manage the Window position
6876
6977
````RAZOR
7078
<p>
@@ -76,17 +84,27 @@ When the [Window `ContainmentSelector` parameter is set](#containmentselector),
7684
<TelerikWindow @bind-Left="@WindowLeft"
7785
@bind-Top="@WindowTop"
7886
Visible="true"
79-
Width="300px">
87+
Width="300px"
88+
@ref="@WindowRef">
8089
<WindowTitle>Window</WindowTitle>
8190
<WindowContent>
82-
The values of <code>WindowLeft</code> and <code>WindowTop</code> change after the user ends dragging or resizing.
91+
The values of <code>WindowLeft</code> and <code>WindowTop</code> change after the user ends dragging, resizing or centering the window.
8392
</WindowContent>
93+
<WindowFooter>
94+
<TelerikButton OnClick="@CenterWindow">Center Window</TelerikButton>
95+
</WindowFooter>
8496
</TelerikWindow>
8597
8698
@code {
99+
private TelerikWindow WindowRef { get; set; }
87100
private string WindowLeft { get; set; } = "50px";
88-
89101
private string WindowTop { get; set; } = "50px";
102+
103+
private void CenterWindow()
104+
{
105+
WindowLeft = WindowTop = string.Empty;
106+
WindowRef.Refresh();
107+
}
90108
}
91109
````
92110

0 commit comments

Comments
 (0)