헤더가 있고 다양한 메뉴 항목이있는 글로벌 컨텍스트 메뉴 style
/template
이 필요합니다. 내 컨텍스트 메뉴의 메뉴 항목 수가 많아 질 수 있으므로 스크롤을 지원해야합니다.헤더와 스크롤바를 지원하는 컨텍스트 메뉴를 생성해야합니다.
내가 가진 현재 스타일의 문제점은 스크롤링을 지원하지 않는다는 것입니다. 메뉴 항목 수가 화면 크기를 초과하면 스크롤 막대가 표시되지 않습니다.
<Style
TargetType="{x:Type ContextMenu}"
x:Key="ContextMenuStyle">
<Setter
Property="ContextMenu.Template">
<Setter.Value>
<ControlTemplate>
<Border
BorderBrush="#868686"
BorderThickness="1"
Background="#FAFAFA">
<StackPanel
Orientation="Vertical">
<Label
Foreground="White"
Background="Blue">
<Binding
RelativeSource=
"{RelativeSource AncestorType=
{x:Type ContextMenu}}"
Path="PlacementTarget.Tag" />
</Label>
<Grid>
<Rectangle
Margin="1,1,1,1"
Width="25"
HorizontalAlignment="Left"
Fill="#E9EEEE" />
<Rectangle
Margin="26,1,0,1"
Width="1"
HorizontalAlignment="Left"
Fill="#C5C5C5" />
<Rectangle
Margin="27,1,0,1"
Width="1"
HorizontalAlignment="Left"
Fill="#FAFAFA" />
<ScrollViewer
Margin="1,0,1,0"
Style="{DynamicResource
{ComponentResourceKey
ResourceId=MenuScrollViewer,
TypeInTargetAssembly=
{x:Type FrameworkElement}}}"
CanContentScroll="True"
Grid.ColumnSpan="2">
<ItemsPresenter
KeyboardNavigation.DirectionalNavigation=
"Cycle" />
</ScrollViewer>
</Grid>
</StackPanel>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
헤더 작품 위에 했나 스크롤 뷰어를 배치하지만 헤더는 또한 스크롤 -
여기 내가 사용하고 현재 스타일이다.
이것을 달성하는 가장 좋은 방법은 무엇입니까?
감사 Meleak을 dockpanel 당신의 StackPanel에 교체 , 당신 말이 맞아요. 나는 이미 이것을 시도하고 작동하지만 그것은 나를위한 가능한 해결책이 아니다; 높이를 고정하지 않고 해결책을 찾고 있습니다. – akjoshi
@akjoshi : 좋습니다. 스크롤링은 언제 활성화되어야합니까? 스크린 바깥 쪽? –
예, 메뉴 항목 수가 화면에 맞지 않을 때마다; 그냥 장소에 대한 명확한 상황에 맞는 메뉴를 만들 때 (실행시 생성되는) 엄청난 수의 항목으로 구성 될 수 있습니다. – akjoshi