如何在左侧设置扩展器标头和在右侧设置图标

时间:2016-07-15 12:02:13

标签: wpf expander

我有树视图我希望扩展器隐藏/显示treeview.But我想要右侧的扩展器图标和左侧的扩展器标头。就像这个

enter image description here

这就是我所做的

 <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>

它给我输出像这个

enter image description here

我尝试了“flowdirection = right”的exapnder,但它将整个标题以及图标移到右侧。我只想在右侧看看exapnder图标。我可以实现这个。帮助。

1 个答案:

答案 0 :(得分:1)

您可能需要替换扩展器的Template,此按钮已硬编码到其中。