0
UWP를 작성할 목록을 작성 중입니다.하나의 스택 패널에서 다른 스택 패널로 텍스트 전송
두 개의 스택 패널이 나란히 있습니다.
<Grid x:Name="MainGrid" Background="Transparent">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition MaxHeight="65"/>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Grid.ColumnSpan="2" >
<TextBlock Margin="10" FontSize="30">Please enter in an item you wish to complete</TextBlock>
<StackPanel Orientation="Horizontal">
<TextBox MinWidth="200" Name="Input"></TextBox>
<Button Margin="10" Click="ButtonAdd_Click">Add</Button>
</StackPanel>
<TextBlock Margin="10" FontSize="30">Below are the Items you need to complete</TextBlock>
</StackPanel>
<StackPanel x:Name="outputArea" Grid.Column="0" Grid.Row="1" >
</StackPanel>
<StackPanel x:Name="completedList" Grid.Column="1" Grid.Row="1">
</StackPanel>
<Button Grid.Column="0" Grid.Row="2" HorizontalAlignment="Left" Click="ButtonSettings_Click">Settings</Button>
<Button Grid.Column="1" Grid.Row="2" HorizontalAlignment="Right" Click="ButtonClear_Click">Clear done</Button>
</Grid>
</Page>
outputArea의 StackPanel에 사용자가 입력 한 텍스트를 포함한다.
C# 코드
private void ButtonAdd_Click(object sender, RoutedEventArgs e)
{
StackPanel sp = new StackPanel(); ;
TextBox textbox = new TextBox();
textbox.Text += Input.Text;
textbox.IsReadOnly = true;
CheckBox done = new CheckBox();
done.Content = "check when done";
done.Checked += Done_Checked;
sp.Orientation = Orientation.Horizontal;
sp.Children.Add(textbox);
sp.Children.Add(done);
outputArea.Children.Add(sp);
}
이 코드 내 문제는 출력 영역에 텍스트 상자에 출력이 입력을 얻을 확인란을 선택하면 출력 영역에서 완성 된 List로 텍스트를 이동하려고합니다. 아래에서 다음을 시도했습니다.
private void Done_Checked(object sender, RoutedEventArgs e)
{
// find the parent horiz sp, and move it.
TextBox textbox = new TextBox();
textbox.Text += textbox.Text;
textbox.IsReadOnly = true;
StackPanel stackpanel = new StackPanel();
stackpanel.Orientation = Orientation.Horizontal;
stackpanel.Children.Add(textbox);
}
미리 감사드립니다.
당신이 completedList.Children.Add (StackPanel을)를 설정되지 않은; done_checked 이벤트에서 –