[C#]WrapPanel

강서현·2022년 4월 9일
0

C#

목록 보기
15/23

버튼안에 TextBlock세개를 넣어 WrapPanel로 묶어주기

XAML

<Grid x:Name="grid1" Background="Orange">
      <Button FontWeight="Bold" Margin="30" FontSize="30">
          <WrapPanel>
            <TextBlock Foreground="Blue">Multi</TextBlock>
            <TextBlock Foreground="Red">Color</TextBlock>
            <TextBlock>Button</TextBlock>
          </WrapPanel>
      </Button>
 </Grid>

C#

Button btn = new Button();
btn.FontWeight = FontWeights.Bold;

WrapPanel pnl = new WrapPanel();

TextBlock txt = new TextBlock();
txt.Text = "Multi";
txt.Foreground = Brushes.Blue;
pnl.Children.Add(txt);

txt = new TextBlock();
txt.Text = "Color";
txt.Foreground = Brushes.Red;
pnl.Children.Add(txt);

txt = new TextBlock();
txt.Text = "Button";
pnl.Children.Add(txt);

btn.Content = pnl;
pnlMain.Children.Add(btn);
profile
Recording...

0개의 댓글