I've looked all over the web for this, and nothing I found seems to help.
I made a model and added the model to a data source as an object. I assumed it would work like a data set where I can just drag and drop onto a form and it would bind the data for me. But it keeps showing blank when I drag and drop from the model. so I looked online and saw that some code-behind was required and this is what I have and its still blank. Any ideas what Im doing wrong?
public partial class form1: Window
{
ComEntities context;;
public form1()
{
InitializeComponent();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
context = new ComEntities();
System.Windows.Data.CollectionViewSource comEntitiesViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("comEntitiesViewSource")));
var permits = (from c in context.tBLPER.Local select c);
this.DataContext = context.tBLPER.Local;
tBLPERDataGrid.ItemsSource = context.tBLPER.Local;
}
}
XAML:
<DataGrid x:Name="tBLPERDataGrid" RowDetailsVisibilityMode="VisibleWhenSelected" Margin="10,10,10,413" ItemsSource="{Binding}" EnableRowVirtualization="True" AutoGenerateColumns="False">
</DataGrid>