admin管理员组文章数量:1122846
I want to set width of items columns the same as the width of listview.headers. the width of headers isn't even as the width of headers. It must be the way to bind these two properties.
<Listview>
<ListView.Header>
<Grid>
<Grid.ColumnDefinitions Width ="1*">
<Grid.ColumnDefinitions Width ="Auto">
<Label
Text = "Title of a book"
Grid.Column ="0"
HorizontalOptions= "StartAndExpand"/>
<Label
Text = "Date"
Grid.Column ="1"
HorizontalOptions= "Center"/>
</Grid>
</Listview.Heder>
<Listview.Items>
<ViewCell>
<Grid>
<Grid.ColumnDefinitions Width ="1*">
<Grid.ColumnDefinitions Width ="Auto">
<Label
Text = "{Binding Library}"
Grid.Column ="0"
LineBreakMode=TailTrumcation
HorizontalOptions= "StartAndExpand"/>
<Label
Text = "{Binding RealiseDate}"
Grid.Column ="1"
HorizontalOptions= "Center"/>
</Grid>
</ViewCell>
</Listview.Items>
</Listview>
The columns' width and headers' width aren't. How to bind headers width with items width?
I want to set width of items columns the same as the width of listview.headers. the width of headers isn't even as the width of headers. It must be the way to bind these two properties.
<Listview>
<ListView.Header>
<Grid>
<Grid.ColumnDefinitions Width ="1*">
<Grid.ColumnDefinitions Width ="Auto">
<Label
Text = "Title of a book"
Grid.Column ="0"
HorizontalOptions= "StartAndExpand"/>
<Label
Text = "Date"
Grid.Column ="1"
HorizontalOptions= "Center"/>
</Grid>
</Listview.Heder>
<Listview.Items>
<ViewCell>
<Grid>
<Grid.ColumnDefinitions Width ="1*">
<Grid.ColumnDefinitions Width ="Auto">
<Label
Text = "{Binding Library}"
Grid.Column ="0"
LineBreakMode=TailTrumcation
HorizontalOptions= "StartAndExpand"/>
<Label
Text = "{Binding RealiseDate}"
Grid.Column ="1"
HorizontalOptions= "Center"/>
</Grid>
</ViewCell>
</Listview.Items>
</Listview>
The columns' width and headers' width aren't. How to bind headers width with items width?
Share Improve this question asked yesterday RadekRadek 11 bronze badge New contributor Radek is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.1 Answer
Reset to default 0You can try this code.
<ContentPage.Resources>
<ResourceDictionary>
<ColumnDefinitionCollection x:Key="SharedColumnDefinitions">
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</ColumnDefinitionCollection>
</ResourceDictionary>
</ContentPage.Resources>
<ListView>
<ListView.Header>
<Grid ColumnDefinitions="{StaticResource SharedColumnDefinitions}">
<Label
Text="Title of a book"
Grid.Column="0"
HorizontalOptions="StartAndExpand"/>
<Label
Text="Date"
Grid.Column="1"
HorizontalOptions="Center"/>
</Grid>
</ListView.Header>
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid ColumnDefinitions="{StaticResource SharedColumnDefinitions}">
<Label
Text="{Binding Library}"
Grid.Column="0"
LineBreakMode="TailTruncation"
HorizontalOptions="StartAndExpand"/>
<Label
Text="{Binding ReleaseDate}"
Grid.Column="1"
HorizontalOptions="Center"/>
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
版权声明:本文标题:How to set width of grid column the same as the width of header in xamarin forms lsitview - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736283906a1927124.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论