[Xaml] <ContentPage ~ xmlns:cont="~.~" ~ > <Grid ColumnSpacing="8" RowSpacing="8" Margin="0,0,0,30"> <Grid.RowDefinitions> <RowDefinition Height="100" /> <RowDefinition Height="100" /> <RowDefinition Height="100" /> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="*" /> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <Frame HasShadow="true" BackgroundColor="white" CornerRadius="8" Grid.Row="0" Grid.Column="0" Padding="10,10,10,10"> <Grid> <FlexLayout Direction="Column" JustifyContent="SpaceBetween"> <Label Text="첫번째" FontSize="20" FontAttributes="Bold"/> </FlexLayout> <cont:MyBtn Command="{Binding SELECT_COMMAND}" CommandParameter="" /> </Grid> </Frame> ` <Frame HasShadow="true" BackgroundColor="white" CornerRadius="8" Grid.Row="0" Grid.Column="1" Padding="10,10,10,10"> <Grid> <FlexLayout Direction="Column" JustifyContent="SpaceBetween"> <Label Text="두번째" FontSize="20" FontAttributes="Bold"/> </FlexLayout> <cont:MyBtn Command="{Binding SELECT_COMMAND}" CommandParameter="" /> </Grid> </Frame> <Frame HasShadow="true" BackgroundColor="white" CornerRadius="8" Grid.Row="0" Grid.Column="0" Padding="10,10,10,10"> <Grid> <FlexLayout Direction="Column" JustifyContent="SpaceBetween"> <Label Text="세번째" FontSize="20" FontAttributes="Bold"/> </FlexLayout> <cont:MyBtn Command="{Binding SELECT_COMMAND}" CommandParameter="" /> </Grid> </Frame> </Grid> |
[C#] FlexLayout flexLayout = new FlexLayout(); ~~
Grid grid = new Grid(); ~~
grid.Children.Add(flexLayout); Frame frame = new Frame(); frame.HasShadow = true; frame.BackgroundColor = Color.White; frame.CornerRadius = 8; frame.Padding = new Thickness( 10, 10, 10, 10); frame.SetValue(Grid.RowProperty, 0); frame.SetValue(Grid.ColumnProperty, 0); frame.Content = grid;
Grid GridBindingTest = new Grid(); GridBindingTest.Children.Add(frame); |
일단 특정 Grid에 Frame을 비하인드 코드에서 동적으로 넣어주는게 목표임
현재 해놓은 코드는 위와 같은데
마지막 GridBindingTest 변수를 목표가 되는 Grid에 바인딩 해주면 될꺼 같은데 그 방법을 모르겠어!
그리고 cont.MyBtn 커맨드도 비하인드에서 어떻게 해줘야할지... 모르겠다
ye
Visibility를 Triggering 하는게 편하지 않겠슴?
집에가게해줘
다 만들어두고 필요에 따라 visibility를 변경하는게 어떻겠냐는 말이지?
ye
ㅇㅇ 나도 code-behind 로 직접 제어하는건 별로 선호하지않아서
집에가게해줘
내가 c++만 해봤어서 WPF를 잘 모르지만
나도 항상 xaml쪽에서만 생성했는데.. 이렇게 동적으로 생성할 때는 ListView나 그런거 쓸 때만 그렇게 하고.
그런데 이번엔 Frame을 버튼처럼 필요한 만큼만 사용할 예정이라
비하인드 코드에서 동적으로 생성해줄 수 밖에 없음...
이걸 어떡하지 ㅋㅋㅋㅋ ㅜㅜ