2011-05-12 72 views
2

手風琴控制,我找了一個手風琴控制WPF .NET 4我需要WPF 4

我知道Codeplex上的WPF工具包具有手風琴控制的,但指出它與兼容.NET 3.5。它會在第4版中起作用嗎?

回答

4

是,該工具包中手風琴與.NET完全兼容4

+0

Thanks Bas,我已經添加了WPF Toolkit dll引用以及xml命名空間並開始使用Accordion。但它似乎沒有正確顯示: – leinad13 2011-05-12 14:41:22

+0

[鏈接] http://www1.picturepush.com/photo/a/5641074/220/5641074.png – leinad13 2011-05-12 14:47:10

+2

我認爲這是預期的行爲,如果你不喜歡外觀您可以更改控件模板。 – Bas 2011-05-14 11:24:26

1

我們爲擴展器的部分創建了一個ListBox的自定義樣式。這使我們可以通過簡單地設計擴展器樣式來自定義菜單項的外觀和風格(即彙總按鈕,當無效時爲紅色等)。下面是一個代碼片段,可以作爲起點,您可以自定義它以適合您需要。注意:使用IsSelected綁定IsExpanded使其一次只能打開一個擴展器,如果想要一次打開多個擴展器,只需將其刪除即可。

 <Style x:Key="VerticalListBoxWithAutoScroll" TargetType="{x:Type ListBox}"> 
     <Setter Property="SnapsToDevicePixels" Value="true"/> 
     <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/> 
     <Setter Property="ScrollViewer.CanContentScroll" Value="true"/> 
     <Setter Property="Template"> 
      <Setter.Value> 
       <ControlTemplate> 
        <Grid> 
         <ScrollViewer x:Name="scrollviewer"> 
          <ScrollViewer.Template> 
           <ControlTemplate TargetType="{x:Type ScrollViewer}" > 
            <Grid > 

             <ScrollBar x:Name="PART_VerticalScrollBar" Orientation="Vertical" 
                  Value="{TemplateBinding VerticalOffset}" 
                  Maximum="{TemplateBinding ScrollableHeight}" 
                  ViewportSize="{TemplateBinding ViewportHeight}" 
                  Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" 
                  Width="{Binding Width, ElementName=Panel}"> 
              <ScrollBar.Template> 
               <ControlTemplate> 
                <Track x:Name="PART_Track"> 
                 <Track.DecreaseRepeatButton> 
                  <RepeatButton Command="ScrollBar.PageUpCommand" 
                      Background="White" BorderBrush="Transparent"/> 
                 </Track.DecreaseRepeatButton> 
                 <Track.IncreaseRepeatButton> 
                  <RepeatButton Command="ScrollBar.PageDownCommand" 
                      Background="White" BorderBrush="Transparent"/> 
                 </Track.IncreaseRepeatButton> 
                 <Track.Thumb> 
                  <Thumb BorderBrush="Transparent" 
                    Background="White" Opacity="0.8" /> 
                 </Track.Thumb> 
                </Track> 
               </ControlTemplate> 
              </ScrollBar.Template> 
             </ScrollBar> 
             <ScrollContentPresenter Height="Auto" VerticalAlignment="Center"/> 
            </Grid> 
           </ControlTemplate> 
          </ScrollViewer.Template> 
          <ItemsPresenter/> 
         </ScrollViewer> 
         <Grid x:Name="Panel"> 
          <Grid.ColumnDefinitions> 
           <ColumnDefinition Width="*" /> 
          </Grid.ColumnDefinitions> 
          <Grid.RowDefinitions> 
           <RowDefinition Height="Auto"/> 
           <RowDefinition Height="*" /> 
           <RowDefinition Height="Auto" /> 
          </Grid.RowDefinitions> 
          <RepeatButton Grid.Row="0" x:Name="LineUpButton" Height="30" Width="80" HorizontalAlignment="Center" Opacity="0" Visibility="Collapsed" 
            Style="{StaticResource ScrollBarLineButton}" 
            Content="M 0 8 L 8 8 L 4 0 Z"  
            Command="{x:Static ScrollBar.LineUpCommand}"  
            CommandTarget="{Binding ElementName=scrollviewer}" 
            ClickMode="Hover" /> 
          <RepeatButton Grid.Row="2" x:Name="LineDownButton" Height="30" Width="80" HorizontalAlignment="Center" Opacity="0" Visibility="Collapsed" 
            Style="{StaticResource ScrollBarLineButton}" 
            Content="M 0 0 L 4 8 L 8 0 Z" 
            Command="{x:Static ScrollBar.LineDownCommand}"  
            CommandTarget="{Binding ElementName=scrollviewer}" 
            ClickMode="Hover"/> 
         </Grid> 
        </Grid> 
        <ControlTemplate.Triggers> 
         <MultiTrigger> 
          <MultiTrigger.Conditions> 
           <Condition Property="IsMouseOver" Value="True"/> 
           <Condition Property="ComputedVerticalScrollBarVisibility" SourceName="scrollviewer" Value="Visible"/> 
          </MultiTrigger.Conditions> 
          <MultiTrigger.EnterActions> 
           <BeginStoryboard> 
            <Storyboard> 
             <DoubleAnimation Storyboard.TargetName="LineUpButton" 
                 Storyboard.TargetProperty="Opacity" To="0.8" Duration="0:0:0.25"/> 
             <DoubleAnimation Storyboard.TargetName="LineDownButton" 
                 Storyboard.TargetProperty="Opacity" To="0.8" Duration="0:0:0.25"/> 
            </Storyboard> 
           </BeginStoryboard> 
          </MultiTrigger.EnterActions> 
          <MultiTrigger.ExitActions> 
           <BeginStoryboard> 
            <Storyboard> 
             <DoubleAnimation Storyboard.TargetName="LineUpButton" 
                 Storyboard.TargetProperty="Opacity" To="0" Duration="0:0:0.25"/> 
             <DoubleAnimation Storyboard.TargetName="LineDownButton" 
                 Storyboard.TargetProperty="Opacity" To="0" Duration="0:0:0.25"/> 
            </Storyboard> 
           </BeginStoryboard> 
          </MultiTrigger.ExitActions> 
          <Setter TargetName="LineUpButton" Property="Visibility" Value="Visible" /> 
          <Setter TargetName="LineDownButton" Property="Visibility" Value="Visible" /> 
         </MultiTrigger> 
        </ControlTemplate.Triggers> 
       </ControlTemplate> 
      </Setter.Value> 
     </Setter> 
     <Setter Property="ItemTemplate"> 
      <Setter.Value > 
       <DataTemplate> 
        <StackPanel Background="White"> 
         <Expander Content="{Binding}" Width="Auto" Header="{Binding DisplayName}" 
           IsExpanded="{Binding IsSelected, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListBoxItem}}}" > 
         </Expander> 
        </StackPanel> 
       </DataTemplate> 
      </Setter.Value> 
     </Setter> 
    </Style>