我不知道如何命名,所以我不知道谷歌的目的,所以我决定问这里。
我的XAML代码是:
<Expander ExpandDirection="Right">
<Expander.Header>
<TextBlock Text="PC and Notebook" RenderTransformOrigin=".5,.5">
<TextBlock.LayoutTransform>
<RotateTransform Angle="90" />
</TextBlock.LayoutTransform>
</TextBlock>
</Expander.Header>
<TreeView>
</TreeView>
</Expander>所以我想把这个XAML代码变成代码隐藏(进行一段时间循环)。我一开始很简单:
Expander cat_expander = new Expander();
cat_expander.ExpandDirection = ExpandDirection.Right;我现在的问题是。如何动态添加<Expander.Header>?当控件中有另一个控件时,人们是如何命名这个东西的?
我希望你能理解我的意思。
发布于 2017-04-10 10:36:46
将Header属性设置为TextBlock
Expander cat_expander = new Expander();
cat_expander.ExpandDirection = ExpandDirection.Right;
TextBlock textBlock = new TextBlock();
textBlock.Text = "PC and Notebook";
textBlock.RenderTransformOrigin = new Point(0.5, 0.5);
textBlock.LayoutTransform = new RotateTransform() { Angle = 90 };
cat_expander.Header = textBlock;
cat_expander.Content = new TreeView();https://stackoverflow.com/questions/43320876
复制相似问题