2016-08-04 9 views
1

좋은 아침 유래, 나는 현재 내 ItemsControl에 주변 스크롤에 문제가 발생하고ItemsControl에 [조회수의] 스크롤 막대가 아닌 기능 BindableCollection

에 의해 채워 때. ItemsControl 내용 (내 ListItemViewModel의 인스턴스로 채워진 BindableCollection에 묶여 있음)이 내 윈도우의 경계를 오버플로 할 때 스크롤 막대가 표시되지만 보이지는 않습니다 (가운데에 더 작은 드래그 가능한 막대 없음). 따라서 확장 된 내용을 스크롤 할 수 없습니다. 창을 확장하면 아래 내용이 표시됩니다. CanContentScroll을 true 및 false로 설정하려고 시도했지만 어느 것도 효과가 없습니다. 여기

내베이스이다 :

<Controls:MetroWindow x:Class="DataIntegrator.Views.BaseView" 
     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" 
     xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" 
     xmlns:cal="http://www.caliburnproject.org" 
     xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro" 
     xmlns:cefSharp="clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf"> 
<Grid AllowDrop="True" cal:Message.Attach="[Event Drop] = [Action AddItems($eventArgs)]" Height="Auto" Width="Auto" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"> 
    <Grid.ColumnDefinitions> 
     <ColumnDefinition Width="14*"/> 
     <ColumnDefinition Width="5*"/> 
    </Grid.ColumnDefinitions> 
    <Grid.RowDefinitions> 
     <RowDefinition Height="*"/> 
     <RowDefinition Height="28"/> 
    </Grid.RowDefinitions> 
    <ScrollViewer Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" VerticalAlignment="Stretch"> 
     <ItemsControl HorizontalAlignment="Stretch" VerticalAlignment="Stretch" ItemsSource="{Binding List}"> 
      <ItemsControl.ItemTemplate> 
       <DataTemplate> 
        <ContentControl cal:View.Model="{Binding}"/> 
       </DataTemplate> 
      </ItemsControl.ItemTemplate> 
      <ItemsControl.ItemsPanel> 
       <ItemsPanelTemplate> 
        <StackPanel/> 
       </ItemsPanelTemplate> 
      </ItemsControl.ItemsPanel> 
     </ItemsControl> 
    </ScrollViewer> 
    <Button x:Name="Reprocess" Content="Reprocess Selected Elements" Grid.RowSpan="1" Grid.Row="1" Grid.ColumnSpan="1" Grid.Column="1"/> 
</Grid> 

항목 뷰 ItemsControl에 추가되고 :

<UserControl x:Class="DataIntegrator.Views.ListItemView" 
     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" 
     xmlns:local="clr-namespace:DataIntegrator.Views" 
     xmlns:cal="http://www.caliburnproject.org" 
     mc:Ignorable="d" 
     d:DesignHeight="300" d:DesignWidth="300"> 
<Grid Height="20" HorizontalAlignment="Stretch"> 
    <Grid.ColumnDefinitions> 
     <ColumnDefinition Width="4*"/> 
     <ColumnDefinition Width="1"/> 
     <ColumnDefinition/> 
     <ColumnDefinition Width="1"/> 
     <ColumnDefinition Width="30"/> 
    </Grid.ColumnDefinitions> 

    <TextBlock x:Name="File" Grid.ColumnSpan="1" Padding="3" Grid.Column="0" Background="#FF5A5A5A" Foreground="Cyan" ></TextBlock> 
    <TextBlock x:Name="Type" Grid.ColumnSpan="1" Padding="3" Grid.Column="2" Foreground="Cyan" Background="#FF5A5A5A"></TextBlock> 
    <Rectangle Grid.Column="4" Fill="#FF5A5A5A" ></Rectangle> 
    <CheckBox x:Name="Reprocess" HorizontalAlignment="Center" VerticalAlignment="Center" Height="18" Width="18" Grid.Column="4" IsChecked="{ Binding Path=Reprocess, Mode=TwoWay }"/> 
</Grid> 

및리스트 아이템을 추가하는 코드 :

public void AddToList(string filePath) 
    { 
     List.Add(new ListItemViewModel(_eventAggregator){File=filePath}); 
     NotifyOfPropertyChange(() => List); 
    } 

여기서 변수 목록은 이미 선언되고 BindableCollection으로 인스턴스화됩니다.

나는 다음과 같은 사실이 보유하고 내가 caliburn.micro 잘못된 일을 할 수있다 믿는다

  1. 주변 XAML을 변경하지 않고, 단순히 ItemsControl에에 ItemsControl.Items를 추가하면 수동으로 예상 스크롤 동작
  2. 수 있습니다
  3. ItemsPanelTemplate StackPanel의 높이를 설정하면 바인딩 가능한 컬렉션이 영역을 채우고 창을 오버플로 할 때까지 예상되는 스크롤바 동작을 허용합니다 (기능하는 스크롤 막대가 드래그 가능한 막대가없는 경우 바뀝니다).

항목이 화면을 오버런 할 때 다른 스크롤바가 표시되는 것처럼 보이지만 주변 ScrollViewer를 제거하면 화면이 오버런 될 때 스크롤바가 전혀 표시되지 않습니다.

다음에 어디로 가야할 지 혼란스러운 종류의 입력은 크게 감사하겠습니다.

감사합니다!

+0

첫 번째 시험은 caliburn없이 코드 (좀 더 세부 사항) 위에 언급 한 바와 같이 모두 – AnjumSKhan

+0

는 viewmodels 프로그래밍 방식으로 추가되는 경우 대신 하드 코드 ItemsControl에 추가합니다.항목은, 예상되는 동작은 스크롤에 의해 전시되는 즉 <조회수 : ListItemView /> .... <전망 : ListItemView /> '에서 ScrollViewer를 추가 – mdlss

+0

보십시오. CanopentScroll = "True"를'ItemsPanelTemplate'에 넣고 StackPanel을 넣습니다. –

답변

1

그래서 내가 XAML 아래로 테스트 한 명확하게하기 위해 ControlTemplate

<ItemsControl > 
    <ItemsControl.Template> 
    <ControlTemplate> 
     <ScrollViewer VerticalScrollBarVisibility="Auto"> 
      <ItemsPresenter /> 
     </ScrollViewer> 
    </ControlTemplate> 
    </ItemsControl.Template> 
</ItemsControl> 

에 ScrollViwer을 추가하고 난 스크롤 뷰어 및 스크롤을 볼 수 그것은 나를 위해 잘 작동합니다.

보기

<Grid Height="200"> 
    <ItemsControl Grid.Column="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" ItemsSource="{Binding List}"> 
     <ItemsControl.Template> 
      <ControlTemplate> 
       <ScrollViewer VerticalScrollBarVisibility="Visible"> 
        <ItemsPresenter /> 
       </ScrollViewer> 
      </ControlTemplate> 
     </ItemsControl.Template> 
     <ItemsControl.ItemTemplate> 
      <DataTemplate> 
       <TextBlock Text="MynewTest"/> 
      </DataTemplate> 
     </ItemsControl.ItemTemplate> 
     <ItemsControl.ItemsPanel> 
      <ItemsPanelTemplate> 
       <StackPanel ScrollViewer.CanContentScroll="True"/> 
      </ItemsPanelTemplate> 
     </ItemsControl.ItemsPanel> 
    </ItemsControl> 
</Grid> 

뷰 모델

public class ViewModel 
{ 
    public ViewModel() 
    { 
     List = new ObservableCollection<string>() { "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" }; 
    } 
    private ObservableCollection<string> _MyProperty; 
    public ObservableCollection<string> List 
    { 
     get { return _MyProperty; } 
     set { _MyProperty = value; } 
    } 
} 
+0

방금 ​​두 가지를 모두 시도했지만 불행히도 효과가 없었습니다. – mdlss

+0

[이 체크] (http://stackoverflow.com/q/2028459/2470362) –

+0

나는 아무 소용이 그 링크에서 제안을 했어요. scrollviewer 온통 옮겼습니다 및 XAML 측면에서 생각할 수있는 모든 속성을 시도한,이 이유는 Caliburn 데이터 바인딩을 함께 할 수있다 믿습니다. (내가 하드 코딩 할 때 그것을 고려할 때 프로그래밍 방식으로 추가 그들) – mdlss