如何在WPF中将数据源中的一个数据项设置为datagrid中的控件属性?
*
<DataGrid x:Name="grdFilter" Margin="5" SelectionMode="Single" AutoGenerateColumns="False" CanUserSortColumns="False">
<DataGrid.Columns>
<DataGridTextColumn Header="Field" IsReadOnly="True" Binding="{Binding Name}" CellStyle="{StaticResource RowHeader}"/>
<DataGridTextColumn Header="Value" Binding="{Binding Value}" Width="*"/>
<DataGridTemplateColumn >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button x:Name="btnCalendar" Click="btnCalendar_Click">X</Button>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
*
非常感谢
答案 0 :(得分:1)
static class Program
{
private static Form _form1;
private static Form _form2;
public static void Main()
{
_form1 = new MyForm();
_form2 = new MyForm();
_form1.MyTextbox.OnTextChanged += Form1_MyTextBox_TextChanged;
}
private void Form1_MyTextBox_TextChanged(object sender, EventArgs e)
{
_form2.MyTextBox.Text = _form1.MyTextbox.Text;
}
}
}
public class MyForm : Form
{
public TextBox MyTextBox {get;set;}
}