本文介绍了电网分离器和了minWidth的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想设置一个了minWidth 我的列。



了minWidth 可以正确处理 0,但是并不 2.分路器只是不断我拖,可以得到列小于申报了minWidth
的似乎了minWidth 来才能生效,如果列宽有一个数值,而不是自动....有没有一种方法来获取与自动工作或刚 * ??



任何想法?

 <! - 内容区 - > 
<电网X:NAME =ContentGrid
Grid.Row =2>
< Grid.ColumnDefinitions>
< ColumnDefinition了minWidth =32WIDTH =260/>
< ColumnDefinition WIDTH =8/>
< ColumnDefinition了minWidth =100WIDTH =*/>
< /Grid.ColumnDefinitions>

<! - 导航 - >
将; ItemsControl的名称=NavigationRegion
区域:RegionManager.RegionName =NavigationRegion
Grid.Column =0>
< ItemsControl.ItemsPanel>
< ItemsPanelTemplate>
<网/>
< / ItemsPanelTemplate>
< /ItemsControl.ItemsPanel>
< / ItemsControl的>
<! - 分配器 - >
<控制:GridSplitter X:NAME =GridSplitter
Grid.Column =1
VerticalAlignment =拉伸
的Horizo​​ntalAlignment =中心
背景={StaticResource的SplitterBackgroundColor}
宽度=8
UseLayoutRounding =真
了borderThickness =1
BorderBrush =黑
高度=自动/>
<! - 表 - >
< ItemsControl的X:名称=MainRegion
Grid.Column =2
区:RegionManager.RegionName =MainRegion>
< ItemsControl.ItemsPanel>
< ItemsPanelTemplate>
<网/>
< / ItemsPanelTemplate>
< /ItemsControl.ItemsPanel>
< / ItemsControl的>


< /网格和GT;


解决方案

我解决这个问题的方法是设置一个了maxWidth 0
时,SizeChanged 激发我获得 0基于当前 ActualWidth的了maxWidth 价值>



于是我打消了我的了minWidth 2为好。这里的修改:

 <  - 内容区 - > 
<电网X:NAME =ContentGrid
Grid.Row =2>
< Grid.ColumnDefinitions>
< ColumnDefinition了minWidth =32WIDTH =260/>
< ColumnDefinition WIDTH =8/>
< ColumnDefinition WIDTH =*/>
< /Grid.ColumnDefinitions>

...



那么事件设置了maxWidth

  this.SizeChanged + =(S,E)=> 
{
双了maxWidth = this.ActualWidth / 2.0;
this.ContentGrid.ColumnDefinitions [0] = .MaxWidth了maxWidth;
}


I am trying to set a MinWidth for my columns.

MinWidth works correctly for Column 0 but not Column 2. The splitter just keeps dragging and I can get the Column to be less than the declared MinWidthThe MinWidth seems to only take effect if the Column Width has a numeric value rather than Auto.... Is there a way to get that to work with Auto or just * ??

Any ideas?

    <!-- Content Area -->
    <Grid x:Name="ContentGrid"
          Grid.Row="2">
        <Grid.ColumnDefinitions>
            <ColumnDefinition MinWidth="32" Width="260"/>
            <ColumnDefinition Width="8" />
            <ColumnDefinition MinWidth="100" Width="*" />
        </Grid.ColumnDefinitions>

        <!-- Navigation  -->
        <ItemsControl Name="NavigationRegion"
                  Regions:RegionManager.RegionName="NavigationRegion"
                  Grid.Column="0">
            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <Grid/>
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
        </ItemsControl>
        <!-- Splitter -->
        <controls:GridSplitter x:Name="GridSplitter"
                               Grid.Column="1"
                               VerticalAlignment="Stretch"
                               HorizontalAlignment="Center"
                               Background="{StaticResource SplitterBackgroundColor}"
                               Width="8"
                               UseLayoutRounding="True"
                               BorderThickness="1"
                               BorderBrush="Black"
                               Height="Auto"/>
        <!-- Form -->
        <ItemsControl x:Name="MainRegion"
                      Grid.Column="2"
                      Regions:RegionManager.RegionName="MainRegion">
            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <Grid/>
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
        </ItemsControl>


    </Grid>
解决方案

The way I fixed this is to set a MaxWidth for Column 0.When SizeChanged fires I get the MaxWidth value for Column 0 based upon the current ActualWidth

So I removed my MinWidth from Column 2 as well. Here's the modifications:

<!-- Content Area -->
<Grid x:Name="ContentGrid"
      Grid.Row="2">
    <Grid.ColumnDefinitions>
        <ColumnDefinition MinWidth="32" Width="260"/>
        <ColumnDefinition Width="8" />
        <ColumnDefinition Width="*" />
    </Grid.ColumnDefinitions>

...

Then the Event setting MaxWidth

this.SizeChanged += (s, e) =>
{
    double maxWidth = this.ActualWidth / 2.0;
    this.ContentGrid.ColumnDefinitions[0].MaxWidth = maxWidth;
}

这篇关于电网分离器和了minWidth的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-27 17:16