Я пытался добавить данные таблицы из базы данных в сетку данных, используя коллекцию, чтобы сетка данных получала refre sh после выполнения действий с ней. Но не удалось получить данные из базы данных в список сбора наблюдений.
введите код
"
<DataGrid x:Name="g1" ItemsSource="{Binding lstTable3}" SelectionMode="Single"
SelectionUnit="FullRow" HorizontalAlignment="Stretch"
materialDesign:DataGridAssist.CellPadding="7,3,3,3" MinHeight="404" VerticalAlignment="Stretch"
Margin="15,0,10,0" AutoGenerateColumns="False" CanUserDeleteRows="True" CanUserAddRows="false"
MinWidth="625" >
<DataGrid.Columns>
<DataGridTextColumn Width="1*" Header="S.No" />
<DataGridTextColumn Binding="{Binding Id}" Width="1*" Header="S.No" />
<DataGridTextColumn Binding="{Binding Title}" Width="2*" Header="Title"/>
<DataGridTextColumn Binding="{Binding o_rder}" Width="1*" Header="Order"/>
<DataGridTextColumn Binding="{Binding Is_Active}" Width="1*" Header="Is Active"/>
<DataGridTextColumn Binding="{Binding Created_on}" Width="2*" Header="Created On"/>
<DataGridTemplateColumn Width="3*" Header="Action">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Button Style="{StaticResource MaterialDesignFlatButton}" MinWidth="50" Command="{Binding DataContext.ViewCommand,RelativeSource={RelativeSource AncestorType=DataGrid}}" CommandParameter="{Binding Id}" >
<Image Source="NewFolder1/baseline-remove_red_eye-24px.png" HorizontalAlignment="Center" ></Image>
</Button>
<Button Style="{StaticResource MaterialDesignFlatButton}" MinWidth="50" Command="{Binding DataContext.DeleteCommand,RelativeSource={RelativeSource AncestorType=DataGrid}}" CommandParameter="{Binding Id}" >
<Image Source="NewFolder1/baseline-delete_sweep-24px.png" Width="20" Height="20" ></Image>
</Button>
<Button Style="{StaticResource MaterialDesignFlatButton}" MinWidth="50" Command="{Binding DataContext.CheckCommand,RelativeSource={RelativeSource AncestorType=DataGrid}}" CommandParameter="{Binding Id }" >
<Image Source="NewFolder1/baseline-edit-24px.png" Width="20" Height="20" ></Image>
</Button>
</StackPanel>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
"
"
public Collection<Table_3> lstTable3
{
get;
set;
}
public void LoadStudents()
{
ObservableCollection<Table_3> students = new ObservableCollection<Table_3>();
using (var db = new deepakEntities())
{
//students.Add(new Table_3 { Id = , Title = "", o_rder = "", Is_Active = "", Created_on = "" });
lstTable3 = students;
}
}
"