Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
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??
Posted

1 solution

This sample bind a textblock width to it's parent's actual width.
C#
<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>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900