2013-10-29 6 views
0

StackPanel을 (기본적으로 일종의 WinRT 허브 제어)으로 사용하는 ItemsControl을 포함하는 WPF UserControl이 있습니다. 내 ItemsControl 주위에 ScrollViewer을 추가하려고하면 그리고 내용이 ScrollViewerItemsControl 그래서 모든 항목이 해당 UserControl 경계에 맞게 축소, UserControl을ScrollViewer는 스크롤바를 표시하는 대신 내용의 크기를 변경합니다.

의 크기를 확장합니다.

어떻게 든 정확히 내가 scrollviewer가 이런 식으로 행동하는 이유를 누구에게 말해 줄 수 있을지 예상 할 수있는 반대?

여기에 내 UserControl이다

<UserControl x:Class="ContentModule.ContentView" 
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
      mc:Ignorable="d" 
      xmlns:contentModule="clr-namespace:ContentModule" 
      xmlns:regions="http://www.codeplex.com/CompositeWPF" 
      xmlns:statics="clr-namespace:Infrastructure.Statics;assembly=Infrastructure" 
      d:DesignHeight="300" d:DesignWidth="300" d:DataContext="{d:DesignInstance contentModule:ContentViewModel}" 
      VerticalAlignment="Top" HorizontalAlignment="Left"> 
     <ItemsControl regions:RegionManager.RegionName="{x:Static statics:ContentRegions.ContentCollection}"> 
      <ItemsControl.ItemsPanel> 
       <ItemsPanelTemplate> 
        <StackPanel Orientation="Horizontal" /> 
       </ItemsPanelTemplate> 
      </ItemsControl.ItemsPanel> 
     </ItemsControl> 
</UserControl> 

항목이 프리즘 RegionManager 통해 주입된다.

EDIT1 :

UserControl

내 MainForm에 주입지고 있습니다. 좀 더 세부 정보 : 그것은 ContrentControl => ShellRegions.Content (세 번째)

<Grid> 
     <Grid.RowDefinitions> 
      <RowDefinition Height="Auto" /> 
      <RowDefinition Height="Auto" /> 
      <RowDefinition Height="*" /> 
     </Grid.RowDefinitions> 
     <ContentControl Grid.Row="0" cal:RegionManager.RegionName="{x:Static statics:ShellRegions.MainMenu}" /> 
     <ItemsControl Grid.Row="1" cal:RegionManager.RegionName="{x:Static statics:ShellRegions.NavigationBar}" /> 
     <ContentControl Grid.Row="2" cal:RegionManager.RegionName="{x:Static statics:ShellRegions.Content}" /> 
    </Grid> 

편집 2에 할당됩니다. 콘텐츠 저울 예상하지만 ItemsControlScrollBar를 표시하지 않는 한 Form/UserControl의 경계를 변경 (오렌지가 ItemsControl의 항목이며, 회색은 UserControl입니다) this :

ItemsControl는 것 같습니다. ScrollViewer을 추가하면 내용의 경계가 더 이상 변경되지 않고 세로 대신 가로 스크롤이 가능하거나 ScrollBar 속성에 따라 UserControll에 맞게 항목 너비가 변경됩니다.

그러나 나는 스케일링을 유지하고 스크롤 막대를 ItemsControl 하단에 추가 할 수 없습니다.

+1

안녕하세요, 목록 상자를 사용 –

+0

사용자 컨트롤의 배치를 윈도우에 표시 할 수 있습니까? –

+0

@devhedgehog 변경을 시도했지만 항목을 선택할 수 없으므로 ListBox에 다른 작업이 필요합니다. 사실 ItemsControl에 머물고 싶습니다. – Console

답변

0

연구의 전체 하루를 보낸 후 나는 작업 솔루션을 발견했다. :) 왜 모두가 ItemsControl을 좋아합니다. 그 실제로 꽤 덤프. 그것 이벤트 가상화 항목을 참조하십시오, hehe. ListBix는 나쁜 엉덩이입니다.
0

당신은 다음과 같은 일을 시도 할 수 있습니다 :

TRUE로를 A에서 ScrollViewer의 제어 및 설정 CanContentScrol 속성을 감 쌉니다.

더 나아가 ItemsControl의 Panel을 VirtualizingStackPanel로 변경하십시오.

<ItemsControl.ItemsPanel> 
     <ItemsPanelTemplate> 
      <VirtualizingStackPanel Orientation="Horizontal" /> 
     </ItemsPanelTemplate> 
    </ItemsControl.ItemsPanel> 

변경 사항이 적용되는지 또는 이러한 변경 사항이 어떤 새로운 문제인지 알려주십시오.

<ItemsControl regions:RegionManager.RegionName="{x:Static statics:ContentRegions.ContentCollection}"> 
      <ItemsControl.Template> 
       <ControlTemplate> 
        <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Disabled"> 
         <ItemsPresenter/> 
        </ScrollViewer> 
       </ControlTemplate> 
      </ItemsControl.Template> 
      <ItemsControl.ItemsPanel> 
       <ItemsPanelTemplate> 
        <StackPanel Orientation="Horizontal" /> 
       </ItemsPanelTemplate> 
      </ItemsControl.ItemsPanel> 
     </ItemsControl> 
+0

슬프게도, 이것 역시 도움이되지 않습니다. 자세한 설명을 추가하겠습니다. – Console

+0

ScrollViewer가 보이지 않습니다. 어디 있니? –

관련 문제