相对于listview标题模板设置文本框的宽度和高度... [英] Set width and height of textbox with respect to listview header template...

查看:77
本文介绍了相对于listview标题模板设置文本框的宽度和高度...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个listview,我在listview中有一个标题模板。在那个标题模板中我有一个文本框。如何设置文本框的宽度和高度相对于标题模板的宽度和高度?

i have a listview and i have a header template in that listview.In that header template i have a textbox.How can i set width and height of the textbox with respect to the header template's width and height??

推荐答案

此示例将文本块宽度绑定到其父级的实际宽度。

This sample bind a textblock width to it's parent's actual width.
<Grid>
 <ListView>
   <ListView.ItemTemplate>
     <DataTemplate>
       <TextBlock Text="{Binding Mode=OneWay}" Background="LightGreen" Foreground="Red"
                Width="{Binding ActualWidth,
                  RelativeSource={RelativeSource AncestorType={x:Type ListView}}}" />
     </DataTemplate>
   </ListView.ItemTemplate>
   <sys:String>Merry</sys:String>
   <sys:String>Christmas</sys:String>
 </ListView>
</Grid>


这篇关于相对于listview标题模板设置文本框的宽度和高度...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆