Current filter:
                                You should refresh the page.
                                  • Hi, I put a TreeList Control in a LayoutPanel, in which I also have a Button and a BarButtonItem. BarButtonItem function ItemClick="Refresh" works well, but Button function Click="Refresh2" does not work. Can you please help me modify the "Refresh2" function in order to realize the same function as "Refresh" ?

                                    <dxdo:LayoutPanel x:Name="paneToolbox" >
                                                        <dxdo:LayoutPanel.CaptionTemplate>
                                                            <DataTemplate>
                                                                <StackPanel Orientation="Horizontal">
                                                                        <Button Click="Refresh2" Grid.Row="1" Grid.Column="0">
                                                                            <StackPanel Orientation="Horizontal">
                                                                                <Image Source="{dx:DXImage Image=Refresh_16x16.png}" Stretch="Uniform"/>
                                                                                <TextBlock Text="Refresh" VerticalAlignment="Center"/>
                                                                            </StackPanel>
                                                                        </Button>
                                                                </StackPanel>
                                                            </DataTemplate>
                                                        </dxdo:LayoutPanel.CaptionTemplate>
                                                        <dxg:TreeListControl x:Name="treelist" ItemsSource="{Binding TreeViewData  >
                                                            <dxg:TreeListControl.View>
                                                                <dxg:TreeListView x:Name ="view">
                                                                    <dxb:BarManager.DXContextMenu>
                                                                        <dxb:PopupMenu>
                                                                            <dxb:BarButtonItem  Content="Refresh"  ItemClick="Refresh" Glyph="{dx:DXImage Image=Refresh_16x16.png}"/>
                                                                        </dxb:PopupMenu>
                                                                    </dxb:BarManager.DXContextMenu>

                                                                </dxg:TreeListView>
                                                            </dxg:TreeListControl.View>
                                                        </dxg:TreeListControl>
                                    </dxdo:LayoutPanel>

                                    code behind xaml:

                                    private void Refresh(object sender, ItemClickEventArgs e)
                                    {
                                                    DataTable data = Models.CreateTreeOfWS(DBPath);
                                                    treelist.ItemsSource = data;
                                                    treelist.BeginDataUpdate();
                                                    foreach (var node in new TreeListNodeIterator(view.Nodes))
                                                        if (node.Level <= 2)
                                                            node.IsExpanded = true;
                                                        else
                                                            node.IsExpanded = false;
                                                    view.SaveNodesState();
                                                    treelist.EndDataUpdate();
                                                }
                                    }

                                    private void Refresh2(object sender, RoutedEventArgs e)
                                    {
                                                    DataTable data = Models.CreateTreeOfWS(DBPath);
                                                    treelist.ItemsSource = data;
                                                    treelist.BeginDataUpdate();
                                                    foreach (var node in new TreeListNodeIterator(view.Nodes))
                                                        if (node.Level <= 2)
                                                            node.IsExpanded = true;
                                                        else
                                                            node.IsExpanded = false;
                                                    view.SaveNodesState();
                                                    treelist.EndDataUpdate();
                                                }
                                    }

                                1 Solution

                                Creation Date Importance Sort by

                                Hello,

                                If you try to drag your button, you will see that the whole panel is dragged. This happens because DockLayoutManager considers elements from CaptionTemplates as drag elements.

                                To inform DockLayoutManager that this button should not be used to drag and drop your panel, it should be sufficient to change its hit test type. Try setting the attached DockPane.HitTestType property to Content in this button:

                                [XAML]
                                xmlns:dxdove="http://schemas.devexpress.com/winfx/2008/xaml/docking/visualelements" ... <Button dxdove:DockPane.HitTestType="Content" Click="Refresh2" Grid.Row="1" Grid.Column="0"> ...

                                Let me know your results.

                                Thanks,
                                Andrey

                                • Customer84449 10.10.2019

                                  It works very well. Thank you.

                                • Andrey Marten (DevExpress Support) 10.10.2019

                                  That's great! You are always welcome!
                                  Andrey