调整wpf中的dataGrid列的大小 [英] Resize dataGrid column in wpf

查看:306
本文介绍了调整wpf中的dataGrid列的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好



请告诉我如何将两个datagrid列添加为一列

例如

i有一个列项宽度= 60

另一个我有Set的宽度= 40



所以我想添加宽度Set Column to Item列。

所以项目列将变为100



请告诉我该怎么做..



谢谢

解决方案

查看此内容





< window>

xmlns =http://schemas.microsoft.com/winfx/2006/xaml/presentation

xmlns:x =http://schemas.microsoft.com/winfx/2006/xaml

xmlns:d =http://schemas.microsoft.com/expression/blend/2008 xmlns:mc =http://schemas.openxmlformats.org/markup-compatibility/2006xmlns:ed =http://schemas.microsoft.com/expression/2010/drawingxmlns:local =clr-namespace :WpfStepByStep1mc:Ignorable =d

x:Class =WpfStepByStep1.MainWind ow

x:Name =Window

Title =reponsiveHeight =600Width =825ResizeMode =CanResizeWithGrip>





< window.datacontext>

< local:addressbookviewmodel x:name =ViewModelxmlns:x = #unknownxmlns:local =#unknown>









< grid x:name =LayoutRootxmlns:x =#unknown>

< textblock horizo​​ntalalignment =Leftmargin =8,8,0,0 textwrapping =Wraptext =Address Bookverticalalignment =Top>

< listbox x:name =___ No_Name_margin =8,62,0,65horizo​​ntalalignment = leftwidth =213itemssource ={Binding Contacts}selecteditem ={Binding SelectedContact}displaymemberpath =Name> < textblock horizo​​ntalalignment =Leftmargin =237,62,0,0textwrapping =Wraptext =Address Bookverticalalignment =Top>

< textblock horizo​​ntalalignment = leftmargin =238,119,0,0textwrapping =Wraptext =Nameverticalalignment =Top>

< textbox horizo​​ntalalignment =Rightmargin =0,116, 44.446,0textwrapping =Wraptext ={Binding SelectedContact.Name}verticalalignment =Topwidth =226.553>

< textblock horizo​​ntalalignment =leftmargin = 238,144.96,0,0textwrapping =Wraptext =E-Mailverticalalignment =Top>

< textbox horizo​​ntalalignment =Rightmargin =0,141.96,44.446,0 textwrapping =Wraptext ={Binding SelectedContact.Email}verticalalignment =Topwidth =226.553>

< textblock horizo​​ntalalignment =Leftmargin =238,170.92,0, 0textwrapping =Wraptext =Phoneverticalalignment =Top>

< textbox horizo​​ntalalignment =Rightmargin =0,167.92,44.446,0textwrapping =W raptext ={Binding SelectedContact.PhoneNumber}verticalalignment =Topwidth =226.553>





< textbox height =23horizo​​ntalalignment =Leftmargin =532,207,0,0name =textBox1verticalalignment =Topwidth =227>



Hi all

Please tell me how to add two datagrid column in as a single column
e.g.
i have one column Item whose width=60
and another i have Set whose width=40

So i want to add the width of the Set Column to Item column.
So item column will become 100

Please tell me how to do that..

Thank you

解决方案

See this one


<window>
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:ed="http://schemas.microsoft.com/expression/2010/drawing" xmlns:local="clr-namespace:WpfStepByStep1" mc:Ignorable="d"
x:Class="WpfStepByStep1.MainWindow"
x:Name="Window"
Title="reponsive" Height="600" Width="825" ResizeMode="CanResizeWithGrip" >


<window.datacontext>
<local:addressbookviewmodel x:name="ViewModel" xmlns:x="#unknown" xmlns:local="#unknown">




<grid x:name="LayoutRoot" xmlns:x="#unknown">
<textblock horizontalalignment="Left" margin="8,8,0,0" textwrapping="Wrap" text="Address Book" verticalalignment="Top">
<listbox x:name="___No_Name_" margin="8,62,0,65" horizontalalignment="Left" width="213" itemssource="{Binding Contacts}" selecteditem="{Binding SelectedContact}" displaymemberpath="Name"> <textblock horizontalalignment="Left" margin="237,62,0,0" textwrapping="Wrap" text="Address Book" verticalalignment="Top">
<textblock horizontalalignment="Left" margin="238,119,0,0" textwrapping="Wrap" text="Name" verticalalignment="Top">
<textbox horizontalalignment="Right" margin="0,116,44.446,0" textwrapping="Wrap" text="{Binding SelectedContact.Name}" verticalalignment="Top" width="226.553">
<textblock horizontalalignment="Left" margin="238,144.96,0,0" textwrapping="Wrap" text="E-Mail" verticalalignment="Top">
<textbox horizontalalignment="Right" margin="0,141.96,44.446,0" textwrapping="Wrap" text="{Binding SelectedContact.Email}" verticalalignment="Top" width="226.553">
<textblock horizontalalignment="Left" margin="238,170.92,0,0" textwrapping="Wrap" text="Phone" verticalalignment="Top">
<textbox horizontalalignment="Right" margin="0,167.92,44.446,0" textwrapping="Wrap" text="{Binding SelectedContact.PhoneNumber}" verticalalignment="Top" width="226.553">


<textbox height="23" horizontalalignment="Left" margin="532,207,0,0" name="textBox1" verticalalignment="Top" width="227">


这篇关于调整wpf中的dataGrid列的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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