WPF:标准和类似于`SplitContainer`的东西?

时间:2011-02-14 12:12:46

标签: c# wpf

WPF中的Windows窗体 SplitContainer是否标准且类似?

我对网格有点失落,因为控件似乎不是在细胞内,而是在它们之上:s。

我做了一些谷歌搜索,但我不确切知道在搜索字段中要写什么...

5 个答案:

答案 0 :(得分:24)

如何使用网格制作水平SplitContainer 以及像SnowBear一样GridSplitter的示例说:

<Window x:Class="JobFinder1.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="JobFinder1" Height="350" Width="525" AllowsTransparency="False">
<Grid Name="gridMain">
    <Grid.RowDefinitions>
        <RowDefinition Height="26" />
        <RowDefinition />
        <RowDefinition Height="1"/>
        <RowDefinition />
    </Grid.RowDefinitions>

    <ToolBar Height="26" VerticalAlignment="Stretch" HorizontalAlignment="Left" />
    <ListView Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
    <GridSplitter Background="DarkGray"  ResizeDirection="Rows" Grid.Row="2" 
                  HorizontalAlignment="Stretch" VerticalAlignment="Stretch" 
                  ResizeBehavior="PreviousAndNext" />
    <ListView Grid.Row="3" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
</Grid>

答案 1 :(得分:20)

网格+ GridSplitter为您服务

答案 2 :(得分:1)

Grid + GridSplitter很痛苦。好吧,他们很容易,但有点难以实现丑陋的Xaml,如果你处于设计阶段并重新安排很多东西,有时很难维护。

您可能正在寻找类似的东西

http://wpfsplitcontainer.codeplex.com/

注意:在使用

之前检查许可证

答案 3 :(得分:1)

  

这是一个简单的控制,需要更多的爱,但嘿,是吗?   工作...

 public static void main( String[] args )
         {
   if(args.length < 2)
   {
   System.err.println("Usage: java -jar lab5.jar infile outfile");
   System.exit(99);
   }

   Cruncher dataManipulator = new Cruncher(args[0], args[1]);

   dataManipulator.openFiles();
   dataManipulator.findDistance();
   dataManipulator.writeRecords();
   dataManipulator.closeFiles();
 }
  String oneCity = "British Columbia:Vancouver:49° 17' N:123° 8' W";
        String twoCity = "Ontario:Hamilton:43° 15' N:79° 52' W";
        String[] source;
        String[] rawLatitude;
        String[] rawLongitude;
        int sourceLatDegrees;
        int sourceLatMinutes;

        if(twoCity.matches("Ontario:Hamilton.*")){
                source = twoCity.split(":");
                for(String inspect: source){
                        System.out.printf("%s\n", inspect);
                }
                rawLatitude = source[2].split("\\D+");
                for(String inspect: rawLatitude){
                     System.out.printf("%s\n", inspect);
                }
                sourceLatDegrees = Integer.parseInt(rawLatitude[0]);
                sourceLatMinutes = Integer.parseInt(rawLatitude[1]);
                System.out.printf("source lat degrees %d source lat minutes %d\n", 
                        sourceLatDegrees, sourceLatMinutes);
        }

         double earthRadius = 6371;   // in km
         double distance = Math.acos(Math.sin(Lat1) * Math.sin(Lat2) + 
                 Math.cos(Lat1) * Math.cos(Lat2) *
                 Math.cos(Long2 - Long1)) * earthRadius;

         public static double rad2deg(double rad) {

  return (rad * 180.0 / Math.PI);

} 

 } 

答案 4 :(得分:0)

另一个,没有GPL许可证

http://www.codeproject.com/Articles/293396/Teh-Simple-but-Useful-WPF-Container

来自Microsoft的GridSplitter tutorial也非常方便。这是一个扩展示例,包括水平和垂直大小调整。 (注意GridSplitter&lt; strong> Horizo​​ntalAligment 和 ResizeDirection )。

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition />
        <RowDefinition Height="Auto" />
        <RowDefinition MinHeight="70" />
    </Grid.RowDefinitions>
    <Grid Grid.Row="0">
        <Grid.ColumnDefinitions>
            <ColumnDefinition />
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition MinWidth="70" />
        </Grid.ColumnDefinitions>
        <DockPanel Grid.Column="0" Background="LightBlue" ></DockPanel>
        <GridSplitter Grid.Column="1" HorizontalAlignment="Stretch" ResizeDirection="Columns" Height="Auto" Width="3" />
        <Grid Grid.Column="2" Background="PaleGoldenrod" ></Grid>
    </Grid>
    <GridSplitter Grid.Row="1" HorizontalAlignment="Stretch" ResizeDirection="Rows" Height="3" Width="Auto" />
    <DockPanel Grid.Row="2" Background="Green" ></DockPanel>
</Grid>