Fork me on GitHub

ToolBar

 

这个例子给了四个组合,如下图。ToolBar只是控件的嵌套。

如图

 

XAML代码:

<Grid Background ="White" >

<Grid.ColumnDefinitions>

<ColumnDefinition Width="300"/>

<ColumnDefinition Width="250"/>

</Grid.ColumnDefinitions>

<Grid.RowDefinitions>

<RowDefinition Height="0.147*"/>

<RowDefinition Height="0.154*"/>

<RowDefinition Height="0.265*"/>

<RowDefinition Height="0.124*"/>

<RowDefinition Height="0.311*"/>

<RowDefinition Height="0*"/>

<RowDefinition Height="0*"/>

<RowDefinition Height="0*"/>

<RowDefinition Height="0*"/>

<RowDefinition Height="0*"/>

<RowDefinition Height="0*"/>

<RowDefinition Height="0*"/>

<RowDefinition Height="0*"/>

<RowDefinition Height="0*"/>

</Grid.RowDefinitions>

<TextBlock Margin="10,10,3,3" Grid.Column="0" Grid.Row="0" FontSize="24">Tool Bars

</TextBlock>

<DockPanel Margin="10,10,3,3" Grid.Column="0" Grid.Row="1">

        <ToolBarTray Background="White">

            <ToolBar Band="1" BandIndex="1">

                <Button><Image Source="toolbargraphics\new.bmp" /></Button>

                <Button><Image Source="toolbargraphics\open.bmp" /></Button>

                <Button><Image Source="toolbargraphics\save.bmp" /></Button>

                <Separator/>

                <Button><Image Source="toolbargraphics\cut.bmp" /></Button>

                <Button><Image Source="toolbargraphics\copy.bmp" /></Button>

                <Button><Image Source="toolbargraphics\paste.bmp" /></Button>

                <Separator/>

                <Button><Image Source="toolbargraphics\print.bmp" /></Button>

                <Button><Image Source="toolbargraphics\preview.bmp" /></Button>

           </ToolBar>

        </ToolBarTray>

</DockPanel>

 

<TextBlock Margin="10,0,3,0" Grid.Column="1" Grid.Row="1" FontSize="12"

    TextWrapping="WrapWithOverflow" VerticalAlignment="Center" Text="单行工具栏"/>

 

<DockPanel Margin="10,10,3,3" Grid.Column="0" Grid.Row="2">

<ToolBarTray Background="White">

            <ToolBar Band="1" BandIndex="1">

                <Button><Image Source="toolbargraphics\cut.bmp" /></Button>

                <Button><Image Source="toolbargraphics\copy.bmp" /></Button>

                <Button><Image Source="toolbargraphics\paste.bmp" /></Button>

           </ToolBar>

           <ToolBar Band="2" BandIndex="1">

                <Button><Image Source="toolbargraphics\undo.bmp" /></Button>

                <Button><Image Source="toolbargraphics\redo.bmp" /></Button>

           </ToolBar>

           <ToolBar Band="2" BandIndex="2">

                <Button><Image Source="toolbargraphics\paint.bmp" /></Button>

                <Button><Image Source="toolbargraphics\spell.bmp" /></Button>

                <Separator/>

                <Button><Image Source="toolbargraphics\save.bmp" /></Button>

                <Button><Image Source="toolbargraphics\open.bmp" /></Button>

           </ToolBar>

        </ToolBarTray>

</DockPanel>

<TextBlock Margin="10,0,3,0" Grid.Column="1" Grid.Row="2" FontSize="12"

     TextWrapping="WrapWithOverflow" VerticalAlignment="Center" Text="两行工具栏"/>

<DockPanel Margin="10,10,3,3" Grid.Column="0" Grid.Row="3">

<ToolBarTray Background="White" IsLocked="True">

     <ToolBar Band="1" BandIndex="1">

      <ComboBox Width="130">

         <ComboBoxItem FontFamily="Times New Roman" IsSelected="True">Times New Roman

         </ComboBoxItem>

        <ComboBoxItem FontFamily="Arial">Arial</ComboBoxItem>

         <ComboBoxItem FontFamily="Arial Rounded MT Bold">Arial Rounded MT Bold

         </ComboBoxItem>

      </ComboBox>

      <ComboBox Width="60">

        <ComboBoxItem FontWeight="Normal" IsSelected="True">Normal</ComboBoxItem>

        <ComboBoxItem FontWeight="Bold">Bold</ComboBoxItem>

        <ComboBoxItem FontWeight="Black">Black</ComboBoxItem>

      </ComboBox>

      <ComboBox Width="30">

        <ComboBoxItem IsSelected="True">8</ComboBoxItem>

        <ComboBoxItem>10</ComboBoxItem>

        <ComboBoxItem>12</ComboBoxItem>

      </ComboBox>

    </ToolBar>

</ToolBarTray>

</DockPanel>

<TextBlock Margin="10,0,3,0" Grid.Column="1" Grid.Row="3" FontSize="12"

      TextWrapping="WrapWithOverflow" VerticalAlignment="Center" Text="带有Combobox的工具栏"/>

<DockPanel Margin="10,10,3,3" Grid.Column="0" Grid.Row="4">

<ToolBarTray Background="White" Orientation="Vertical" Grid.RowSpan="2">

            <ToolBar Band="1" BandIndex="1">

                <Button><Image Source="toolbargraphics\copy.bmp" /></Button>

                <Button><Image Source="toolbargraphics\paste.bmp" /></Button>

           </ToolBar>

           <ToolBar Band="2" BandIndex="1" Grid.RowSpan="2">

                <Button><Image Source="toolbargraphics\undo.bmp" /></Button>

                <Button><Image Source="toolbargraphics\redo.bmp" /></Button>

           </ToolBar>

</ToolBarTray>

</DockPanel>

<TextBlock Margin="10,0,3,0" Grid.Column="1" Grid.Row="4" FontSize="12"

     TextWrapping="WrapWithOverflow" VerticalAlignment="Center" Text="竖方向的工具栏"/>          

</Grid>

posted @ 2007-05-07 13:54  桂素伟  阅读(667)  评论(0编辑  收藏  举报