silverlight 怎样在后台改变datagrid标头内容
2个回答
展开全部
写了个Demo给你哈。
前台:
<Grid>
<sdk:DataGrid AutoGenerateColumns="False" Name="dataGrid1">
<sdk:DataGrid.Columns>
<sdk:DataGridTextColumn Header="Name" Binding="{Binding Name}"/>
</sdk:DataGrid.Columns>
</sdk:DataGrid>
</Grid>
后台:
public partial class SilverlightControl1 : UserControl
{
public SilverlightControl1()
{
InitializeComponent();
dataGrid1.ItemsSource = new List<GridData>()
{
new GridData(){Name="aaa"},
new GridData(){Name="bbb"},
new GridData(){Name="ccc"},
new GridData(){Name="ddd"},
new GridData(){Name="eee"}
};
dataGrid1.Columns[0].Header = "Id";
}
}
public class GridData
{
public string Name { get; set; }
}
前台:
<Grid>
<sdk:DataGrid AutoGenerateColumns="False" Name="dataGrid1">
<sdk:DataGrid.Columns>
<sdk:DataGridTextColumn Header="Name" Binding="{Binding Name}"/>
</sdk:DataGrid.Columns>
</sdk:DataGrid>
</Grid>
后台:
public partial class SilverlightControl1 : UserControl
{
public SilverlightControl1()
{
InitializeComponent();
dataGrid1.ItemsSource = new List<GridData>()
{
new GridData(){Name="aaa"},
new GridData(){Name="bbb"},
new GridData(){Name="ccc"},
new GridData(){Name="ddd"},
new GridData(){Name="eee"}
};
dataGrid1.Columns[0].Header = "Id";
}
}
public class GridData
{
public string Name { get; set; }
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询