0
A
답변
1
당신은 "빈"영역에 대한 데이터 그리드 자체에의 ContextMenu를 할당 할 수 있지만 그것은 또한 당신이 오른쪽 버튼으로 모든 행에 나타납니다 행 (또는 "DataGrid.RowStyle"속성)에 다른 상황에 맞는 메뉴가 지정되어 있지 않으면 클릭하십시오.
'해결 방법'은 간단히 행에 다른 컨텍스트 메뉴를 지정하는 것입니다.
<DataGrid>
<DataGrid.ContextMenu>
<ContextMenu>
<MenuItem Header="Menu Item in Blank Area" />
</ContextMenu>
</DataGrid.ContextMenu>
<DataGrid.RowStyle>
<Style TargetType="{x:Type DataGridRow}">
<Setter Property="ContextMenu">
<Setter.Value>
<ContextMenu>
<MenuItem Header="Menu Item just for Populated Rows" />
</ContextMenu>
</Setter.Value>
</Setter>
</Style>
</DataGrid.RowStyle>
</DataGrid>
1
는 이전의 대답에 귀하의 의견을 바탕으로, 나는 당신이 당신의 헤더에 하나의 ContextMenu를 설정하려는 것을보고, 당신의 세포와 빈 공간을위한 별도의 하나. 나는 템플릿을 대체하여 별도의 ContextMenus을 설정 할 수 있었다 :
<Window x:Class="Apc_System_Generator.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Grid.Resources>
<ResourceDictionary>
<ContextMenu x:Key="cmenu">
<MenuItem Header="FOO" />
<MenuItem Header="BAR" />
</ContextMenu>
<ContextMenu x:Key="omenu">
<MenuItem Header="LOL" />
<MenuItem Header="WUT" />
</ContextMenu>
</ResourceDictionary>
</Grid.Resources>
<DataGrid Name="LOL" AutoGenerateColumns="True" ContextMenu="{StaticResource cmenu}">
<DataGrid.Template>
<ControlTemplate TargetType="{x:Type DataGrid}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<DataGridColumnHeadersPresenter Grid.Row="0" ContextMenu="{StaticResource omenu}" />
<DataGridRowsPresenter Background="gray" Grid.Row="1" IsItemsHost="True" />
</Grid>
</ControlTemplate>
</DataGrid.Template>
</DataGrid>
</Grid>
</Window>
관련 문제
- 1. 프리즘 셸 영역이 MFC에서 호스팅 될 때 채워지지 않음 CView
- 2. SelectList가 채워지지 않습니다.
- 3. ListView가 채워지지 않습니다
- 4. ASEventSourcesTable이 채워지지 않습니다.
- 5. NSDictionary가 채워지지 않습니다
- 6. listView가 채워지지 않습니다?
- 7. TreeView가 채워지지 않습니다
- 8. NSMutableArray가 채워지지 않습니다
- 9. ExtJS JsonStore가 채워지지 않습니다.
- 10. TabWidget이 HorizontalScrollView에 채워지지 않습니다.
- 11. UITable에 NSMutableArray가 채워지지 않습니다.
- 12. Html.DropDownList가 '선택한'면도기에서 채워지지 않습니다.
- 13. InAppSettings이 시작시 채워지지 않습니다.
- 14. UITableView가 SQLite로 채워지지 않습니다
- 15. mvc보기가 데이터로 채워지지 않습니다.
- 16. 콤보 상자가 채워지지 않습니다.
- 17. 백본 컬렉션에 채워지지 않습니다.
- 18. 배열이 함수로 채워지지 않습니다.
- 19. 목록이 채워지지 않습니다.
- 20. BaseAdapter가 listview에 채워지지 않습니다.
- 21. 텍스트 영역이 흐리게 처리되지 않습니다.
- 22. 텍스트 영역이 올바르게 업데이트되지 않습니다.
- 23. Java 텍스트 영역이 게시되지 않습니다.
- 24. Android : ListView가 완전히 채워지지 않습니다.
- 25. DataGridView가 데이터 세트로 채워지지 않습니다
- 26. XSLT 값이 조건에 채워지지 않습니다.
- 27. 결과 집합이 결과로 채워지지 않습니다.
- 28. BLL에서 드롭 다운이 채워지지 않습니다
- 29. ScrollViewer가 전체 화면으로 채워지지 않습니다.
- 30. jqgrid 데이터가 모눈에 채워지지 않습니다
아이디어가 세포와 ("이"사진에로 표시) 세포로 작성되지 영역으로 같은 컨텍스트 메뉴를 지정하는 것입니다. 헤더에 대한 기타 컨텍스트 메뉴. 그게 내가 질문 한 이유 다. – MikroDel
원래 질문을 반영하여 반영하십시오. 대답은 여전히 동일합니다. 요소 (빈 영역과 셀을 포함하여 DataGrid에 모든 효과가 있음)에 대한 컨텍스트 메뉴를 만들고 재정의 할 특정 항목 (이 경우 헤더)에 다른 항목을 할당합니다. –
BTownTKD