728x90
728x170

GridControl 에 Contextmenu 를 표시하는 방법입니다.
TableView 의 ShowGridMenu 이벤트를 이용하여 표시합니다.

        <dxg:GridControl
            Grid.Row="3"
            Height="300"
            ItemsSource="{Binding Items}">
           ......
            <dxg:GridControl.View>
                <dxg:TableView
                    CellStyle="{StaticResource FocusedCellStyle}"
                    RowStyle="{StaticResource FocusedRowStyle}"
                    ShowGroupPanel="False"
                    ShowGridMenu="TableView_ShowGridMenu"/>
            </dxg:GridControl.View>
        </dxg:GridControl>
        private void TableView_ShowGridMenu(object sender, DevExpress.Xpf.Grid.GridMenuEventArgs e)
        {
            BarButtonItem menu1 = new BarButtonItem();
            menu1.Name = "menu1";
            menu1.Content = "Menu1";
            menu1.ItemClick += Menu1_ItemClick;
            menu1.Glyph = new BitmapImage(new Uri("pack://application:,,,/kei.png"));


            BarButtonItem menu2 = new BarButtonItem();
            menu2.Name = "menu2";
            menu2.Content = "Menu2";
            menu2.ItemClick += Menu2_ItemClick;
            menu2.Glyph = new BitmapImage(new Uri("pack://application:,,,/kei.png"));

            e.Customizations.Add(menu1);
            e.Customizations.Add(menu2);
        }
        
        private void Menu1_ItemClick(object sender, ItemClickEventArgs e)
        {

        }

        private void Menu2_ItemClick(object sender, ItemClickEventArgs e)
        {

        }


결과

소스
https://github.com/kei-soft/KJunBlog/tree/master/Wpf.DevGridTest

728x90
그리드형
Posted by kjun.kr
,