다음을 통해 공유


방법: 여러 줄 TextBox 컨트롤 만들기

이 예제는 XAML(Extensible Application Markup Language)을 사용하여 여러 줄 텍스트를 수용하도록 자동으로 확장되는 TextBox 컨트롤을 정의하는 방법을 보여 줍니다.

예제

TextWrapping 특성을 Wrap으로 설정하면 TextBox 컨트롤의 가장자리에 도달할 때 입력된 텍스트가 새 줄로 줄 바꿈되어 필요할 경우 새 줄의 공간을 포함하도록 TextBox 컨트롤을 자동으로 확장합니다.

AcceptsReturn 특성을 true로 설정하면 RETURN 키를 누를 때 새 라인이 삽입되어 필요할 경우 새 줄의 공간을 포함하도록 TextBox가 자동으로 확장됩니다.

VerticalScrollBarVisibility 특성은 TextBox에 스크롤 막대를 추가하여 TextBox가 둘러싼 프레임 또는 창의 크기를 초과할 경우 TextBox의 콘텐츠를 스크롤할 수 있도록 합니다.

<TextBox
  Name="tbMultiLine"
  TextWrapping="Wrap"
  AcceptsReturn="True"
  VerticalScrollBarVisibility="Visible"
>
  This TextBox will allow the user to enter multiple lines of text.  When the RETURN key is pressed, 
  or when typed text reaches the edge of the text box, a new line is automatically inserted.
</TextBox>

참고 항목