Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

That is my custom control code:

<TreeView Name="TreeView1"
                  Width="180"
                  HorizontalAlignment="Left"
                  HorizontalContentAlignment="Left"
                  BorderThickness="0"
                  ItemsSource="{Binding SectionList}">
            <TreeView.ItemTemplate>
                <DataTemplate>
                    <Expander Margin="-20,0,0,0"
                              Padding="0,0,0,0"
                              Header="{Binding Name}"
                              IsExpanded="True">
                        <ListBox Margin="22,0,0,0"
                                 Padding="0,0,0,0"
                                 HorizontalAlignment="Stretch"
                                 HorizontalContentAlignment="Left"
                                 BorderBrush="Transparent"
                                 BorderThickness="0,0,0,0"
                                 IsSynchronizedWithCurrentItem="True"
                                 ItemsSource="{Binding Sections}"
                                 ScrollViewer.CanContentScroll="False"
                                 SelectedValue="{Binding Path=DataContext.Label, RelativeSource={RelativeSource AncestorType={x:Type TreeView}}}"
                                 SelectedValuePath="Text">
                            <ListBox.Template>
                                <ControlTemplate>
                                    <ItemsPresenter />
                                </ControlTemplate>
                            </ListBox.Template>
                        </ListBox>
                    </Expander>
                </DataTemplate>
            </TreeView.ItemTemplate>
        </TreeView>

When the name is too large, scrollbar makes visible and it's okay. But when you scroll horizontally the Expander button is going to left and despair and it's a problem. So, I would like to make Expander ignore scrolling.

First view:

enter image description here

After scroll:

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
776 views
Welcome To Ask or Share your Answers For Others

1 Answer

等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...