网格列对齐 (wpf)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14586696/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
allignment on grid column (wpf)
提问by mans
I have a grid which its columns are centred aligned. For example every image that is on a cell in this grid, is centred on its cell. There is nothing in grid definition that sets this . The grid definition is as follow:
我有一个网格,它的列居中对齐。例如,此网格中单元格上的每个图像都以其单元格为中心。网格定义中没有设置 this 。网格定义如下:
<Grid Canvas.Left="16" Canvas.Top="229" Visibility="{Binding Status,
Converter={StaticResource EnumToVisibilityConverter},
ConverterParameter='OK,Processing'}" IsEnabled="{Binding Status,
Converter={StaticResource EnumToBoolConverter},
ConverterParameter='OK'}" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100" />
<ColumnDefinition Width="150" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="40" />
<RowDefinition Height="40" />
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
</Grid.RowDefinitions>
<Image Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2" Source="image1.png" Stretch="Fill" Width="111" Height="20" />
<Image Grid.Column="0" Grid.Row="1" Source="image2.png" Width="49" Height="17"/>
</Grid>
Both of the above images are centred aligned.
上面两张图片都是居中对齐的。
I checked parent canvas and there is nothing there to dictate that it should be centred. Is there a way that I set the alignment of a grid column to left?
我检查了父画布,没有任何东西可以规定它应该居中。有没有办法将网格列的对齐方式设置为左侧?
Is there any tools that I can see where the property of each component is set? (Similar to what developer toolbar do for CCS and HTML)
是否有任何工具可以查看每个组件的属性设置位置?(类似于开发者工具栏对 CCS 和 HTML 的作用)
回答by sa_ddam213
You could set the HorizontalAlignmentof the Imageto the Left if you need, as I'm pretty sure Centeris the default alignment.
你可以设置HorizontalAlignment的Image到左边,如果你需要,我敢肯定Center是默认的对齐方式。
<Image HorizontalAlignment="Left" ......

