WPF 영역 Show/Hide

Eden·2023년 3월 22일
0

wpf 사용시 특정 영역(grid)이 show/hide 되도록 사용할때 쓰인다

//.xaml
<Grid.ColumnDefinitions>
	<ColumnDefinition/>
    <ColumnDefinition Width="{Binding isShow}"/>
    <ColumnDefinition Width="2*"/>
    <ColumnDefinition/>
</Grid.ColumnDefinitions>
//.cs
private GridLength _isShow = new GridLength(0, GridUnitType.Star); // 

public GridLength isShow
	{
	get { return _isShow; }
	set
	{
		_isShow = value;
		UpdateProperty("isShow"); // Binding에 사용되는 Property 부분 프로젝트마다 사용 방법이 다르다. 
	}
}

public void ChangeGrid()
{
	if(true)
	{
		isShow = new GridLength(1, System.Windows.GridUnitType.Star); //자동 설정 비율 1
	}
    else
    {
    	isShow = new GridLength(0, System.Windows.GridUnitType.Star); //자동 설정 비율 0으로 안보임처리
    }
}
profile
주섬주섬..

0개의 댓글