silverlight 怎样在后台改变datagrid标头内容
展开全部
写了个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; }
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询