【问题标题】:how to set expander header on left side and icon on right side [duplicate]如何在左侧设置扩展器标题并在右侧设置图标[重复]
【发布时间】:2016-07-15 12:02:12
【问题描述】:

我有树视图,我希望扩展器在其中隐藏/显示树视图。但我希望右侧的扩展器图标和左侧的扩展器标题。像这样

这就是我所做的

 <Expander Grid.Row="0" FlowDirection="RightToLeft" >
                    <Expander.Header >
                        <StackPanel Orientation="Horizontal" FlowDirection="LeftToRight" >
                            <TextBlock Foreground="White" FontWeight="Bold">Global Setting</TextBlock>
                            <Path Data="{StaticResource IconGlobalNetworking}" Fill="#07B9D3" Margin="5"></Path>

                            <!--<Path Data="{StaticResource IconGlobalNetworking}" Fill="#07B9D3" Margin="5"></Path>-->
                        </StackPanel>                            
                    </Expander.Header>
                    <TreeView  FlowDirection="LeftToRight" BorderThickness="0" Margin="30,0,0,0">
                        <TreeViewItem>
                            <TreeViewItem.Header>
                                <StackPanel Orientation="Horizontal">
                                    <Path Data="{StaticResource IconServerStack}" Fill="#07B9D3" Margin="5"></Path>
                                    <TextBlock Foreground="White" FontWeight="Bold" Margin="5">Managment Server</TextBlock>
                                </StackPanel>
                            </TreeViewItem.Header>
                        </TreeViewItem>
                        <TreeViewItem>
                            <TreeViewItem.Header>
                                <StackPanel Orientation="Horizontal">
                                    <Path Data="{StaticResource IconSalientServer}" Fill="#07B9D3" Margin="5"></Path>
                                    <TextBlock Foreground="White" FontWeight="Bold" Margin="5">License Server</TextBlock>
                                </StackPanel>
                            </TreeViewItem.Header>
                        </TreeViewItem>
                        <TreeViewItem>
                            <TreeViewItem.Header>
                                <StackPanel Orientation="Horizontal">
                                    <Path Data="{StaticResource IconGlobalNetworking}" Fill="#07B9D3" Margin="5"></Path>
                                    <TextBlock Foreground="White" FontWeight="Bold" Margin="5">Web Server</TextBlock>
                                </StackPanel>
                            </TreeViewItem.Header>
                        </TreeViewItem>
                    </TreeView>
                </Expander>

它给了我这样的输出

我尝试过 exapnder 的“flowdirection=right”,但它会将整个标题和图标移动到右侧。我只想要右侧的 exapnder 图标。我怎样才能实现这一点。请帮助。

【问题讨论】:

  • 你试过旋转两者吗?
  • 在链接中指出这是重复的:&lt;Expander FlowDirection="RightToLeft"&gt; &lt;StackPanel FlowDirection="LeftToRight"&gt;
  • @Kirenenko:严格来说,这不是“轮换”。
  • 我认为如果旋转的中心是元素中间的垂直轴,它就是一个旋转。可能不是最好的想法。
  • 我已经完成了那个链接。它不工作

标签: wpf expander


【解决方案1】:

你可能需要替换扩展器的Template,这个按钮是硬编码的。

【讨论】:

  • 对不起,我不明白。你能简单解释一下
  • @NeelamPrajapati:阅读documentation for the propertyrelated class。您只需重新定义控件的内部组成即可,那里有很多示例。您可能还想找到默认模板,然后您可以修改它,而不必从头开始。
猜你喜欢
  • 2014-04-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-04-29
  • 2020-05-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多