I have this grid
<igWPF:XamDataGrid DataSource="{Binding Path=aktiveUgeaviserMedAlles, Mode=OneWayToSource}" HorizontalAlignment="Left" Grid.Row="8" VerticalAlignment="Top" Height="365" Width="1537" Grid.ColumnSpan="13" Grid.RowSpan="3" Name="dgMediePlanlinjer" Margin="46,28,0,0" GroupByAreaLocation="AboveDataArea" BindToSampleData="True"> <igWPF:XamDataGrid.FieldLayouts> <igWPF:FieldLayout> <igWPF:FieldLayout.Settings> <igWPF:FieldLayoutSettings AutoArrangeCells="Never" AutoGenerateFields="true" /> </igWPF:FieldLayout.Settings> </igWPF:FieldLayout> </igWPF:XamDataGrid.FieldLayouts>
</igWPF:XamDataGrid>
and this method to fill in the data
public void setAviserTilGrid(int bladid) { var res = aviserDao.GetAllUgeAvisTilGrid(bladid, System.DateTime.Now.Year-1, 1); aktiveUgeaviserMeds.Add(res); aktiveUgeaviserMedAlles = new System.Collections.ObjectModel.ObservableCollection<List<AviserTilGrid>>(); aktiveUgeaviserMedAlles.Add(aktiveUgeaviserMeds);
dgMediePlanlinjer.DataSource = aktiveUgeaviserMedAlles ; // MessageBox.Show("Hej August"); }
I can see that there are data in aktiveUgeaviserMedAlles but no data in the Grid
Great! Let us know if you have any additional questions or concerns.
Hi Michael
I found the solution and it was not where I was looking
Hello Thomas,
I put together a sample project to get started on reproducing the behavior. But since there are missing components from your code above I can't continue. I'll need your help finishing up the sample. Please see below. Thanks.
WpfApp12.zip
I forgot this the object in the List that is passed to xamdatagrid
#region Assembly dlu-persistence-api, Version=2.0.9.22, Culture=neutral, PublicKeyToken=null// C:\Users\Thomas Kleist\source\repos\DLUPersistence-service-api\dlu-persistence-api\bin\Release\dlu-persistence-api.dll#endregion
using System.Collections.Generic;
namespace dlu_persistence_api.daos{ public class AviserTilGrid { public AviserTilGrid();
public string OrdredeadlineTekst { get; set; } public string OrdreDeadlineRubrikKl { get; set; } public byte? OrdreDeadlineRubrikDag { get; set; } public string OrdredeadlineRubrik { get; set; } public byte? OrdrecheckSendeDagID { get; set; } public string OrdrecheckEmail { get; set; } public int Oplag { get; set; } public byte? OrdreDeadlineTekstDag { get; set; } public bool Ophoert { get; set; } public string Navn { get; set; } public decimal? MMPris { get; set; } public decimal? mmPris { get; set; } public byte? MedlemMaaned { get; set; } public byte? Medlemaar { get; set; } public byte MaxDaekningsGrad { get; set; } public string MaterialeEmail { get; set; } public string Navn2 { get; set; } public string OrdreDeadlineTekstKl { get; set; } public string OrdreEmail { get; set; } public string OrienteringEmails { get; set; } public bool VisPaaWWW { get; set; } public byte? TotalomraadePct { get; set; } public int? Totalomraade { get; set; } public string Tlf { get; set; } public string StamdataEmail { get; set; } public bool? SendIndevaerendeUge { get; set; } public string SendetidOrdrecheck { get; set; } public string SamannonceringsRabat { get; set; } public string RegionNavn { get; set; } public string RedaktionEmail { get; set; } public string PrislisteNavn { get; set; } public string PrisforespoergselEmails { get; set; } public byte? PrimaerPct { get; set; } public int? Primaer { get; set; } public int? PostNr { get; set; } public string PostBy { get; set; } public bool Overfoert { get; set; } public string MaterialeDeadlineTekstKl { get; set; } public byte? MaterialeDeadlineTekstDag { get; set; } public string MaterialedeadlineTekst { get; set; } public string MaterialeDeadlineRubrikKl { get; set; } public decimal? Farve4Min { get; set; } public decimal? Farve4Max { get; set; } public int FakturaGruppeID { get; set; } public string Emails { get; set; } public string Ejerforhold { get; set; } public string DiMPDelOmraadeKode { get; set; } public string DagNavn { get; set; } public int DaekningsGrad { get; set; } public string BogholderiEmails { get; set; } public string BilagsbladeEmail { get; set; } public string Betegnelse { get; set; } public string AnnonceKontrolEmail { get; set; } public string Adresse2 { get; set; } public string CVR { get; set; } public int BladID { get; set; } public string AnnonceEmail { get; set; } public string Adresse { get; set; } public decimal? Farve4Pris { get; set; } public string WWWDaekningSomTekst { get; set; } public decimal? FarveMax { get; set; } public decimal? FarvePris { get; set; } public byte? MatGodtBeloeb { get; set; } public byte? MaterialeDeadlineRubrikDag { get; set; } public string MaterialedeadlineRubrik { get; set; } public bool? MaaGiveFarveRabat { get; set; } public string KontaktpersonerEmails { get; set; } public string Kontaktperson { get; set; } public string Koncern { get; set; } public int Husstande { get; set; } public string HovedGruppeNavn { get; set; } public string Hjemmeside { get; set; } public string GruppeRabat { get; set; } public bool GiverWebTillaeg { get; set; } public string GeoKodeNavn { get; set; } public int FormatTil { get; set; } public int FormatFra { get; set; } public string Format { get; set; } public string Fax { get; set; } public decimal? FarveMin { get; set; } public List<webtilLæg> webtillages { get; set; } }}
Hello Michael
This is the Class with the Method SetAviserTilGrid that are suppose to populate the Grid I can see my debug session that there are added data to list var in setAviserTilGrid.
Please help because I',m goint nuts here
using Caliburn.Micro;using DDF_sql_services.daos;using dlu_persistence_api.daos;using dlu_persistence_api;using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows;using System.Windows.Controls;using System.Windows.Data;using System.Windows.Documents;using System.Windows.Input;using System.Windows.Media;using System.Windows.Media.Imaging;using System.Windows.Shapes;using Infragistics.Windows.DataPresenter;
namespace LokalPlanner{ /// <summary> /// Interaction logic for MediePlan.xaml /// </summary> public partial class MediePlan : Page { AviserTilGrid AviserTilGrid { get; set; } private List<Annoncøer> annoncør { get; set; } private List<Bureau> Bureau { get; set; } private BureaoDao bureaoDao; private AnnonøcerDAO annonøcerDAO; private DPKuloerDao kuloerDao; private PlaceringDao placeringDao; private MediePlanAviserDao aviserDao; private MediePlanLinjerDao mediePlanLinjerDao; private MedieplanÆndringerDao medieplanÆndringerDao; private MediaPlanNrDao mediaPlanNrDao; private MediePlanDao mediePlanDao;
private System.Collections.ObjectModel.ObservableCollection<List<AviserTilGrid>> aktiveUgeaviserMedAlles = new System.Collections.ObjectModel.ObservableCollection<List<AviserTilGrid>>(); List<AviserTilGrid> aktiveUgeaviserMeds { get; set; } private int placeringid { get; set; }
private int year { get; set; } public MediePlan() { bureaoDao = new BureaoDao(); annonøcerDAO = new AnnonøcerDAO(); Bureau = bureaoDao.GetListbureauer(); annoncør = annonøcerDAO.GetAnnoncøer(); kuloerDao = new DPKuloerDao(); placeringDao = new PlaceringDao(); aviserDao = new MediePlanAviserDao(); aktiveUgeaviserMeds = new List<AviserTilGrid>(); mediePlanDao = new MediePlanDao(); mediePlanLinjerDao = new MediePlanLinjerDao(); mediaPlanNrDao = new MediaPlanNrDao(); medieplanÆndringerDao = new MedieplanÆndringerDao(); InitializeComponent(); setBureaList(); setAnnoncøerList(); setFarveListe(); setPlacering(); }
private void setPlacering() { placeringCombo.DataContext = new { placering = placeringDao.GetPlaceringer()}; } private void setBureaList() { BureauCombo.DataContext = new { bureaus = Bureau }; }
private void setFarveListe() { farver.DataContext = new { farver = kuloerDao.GetDPKuloer() }; } private void setAnnoncøerList() { AnnoncørCombo.DataContext = new { annoncøer = annoncør }; AnnoncørCombo.Text = "-Vælg Annoncør-"; }
private void farve4_Click(object sender, RoutedEventArgs e) {
}
private void farve1_Click(object sender, RoutedEventArgs e) { farve1.Visibility = Visibility.Hidden; farver.Visibility = Visibility.Visible; }
private void Opret_Click(object sender, RoutedEventArgs e) {
private void TilFøjkMediePlanLinjer() { var records = dgMediePlanlinjer.Records; foreach (var record in records) { var item = ((DataRecord)record).DataItem as AviserTilGrid; if (item != null) { var linje = new tblMedieplanLinjer(); var task = mediePlanLinjerDao.CreateOrUpdateMediePlanLinjer(linje); } }
private void opretMediePlanNr() { var table = new tblMedieplanNr(); var res = mediaPlanNrDao.CreateOrUpDateMediePlanNr(table); if(res.Item2 == 1) {
} }
private void opretMediePlanÆndringer() { } private void BureauCombo_SelectionChanged(object sender, SelectionChangedEventArgs e) {
private void AnnoncørCombo_SelectionChanged(object sender, SelectionChangedEventArgs e) { var an = AnnoncørCombo.SelectedItem as Annoncøer; if (an.Bill_to_Contact_No_ != "") { var res = Bureau.Find(s => s.Company_No_ == an.Bill_to_Contact_No_).Annoncør; BureauCombo.Text = res; } else { BureauCombo.Text = an.Annoncør; } }
private void farver_SelectionChanged(object sender, SelectionChangedEventArgs e) { farver.Visibility = Visibility.Hidden; farve1.Visibility = Visibility.Visible; }
public void setAviserTilGrid(List<int> bladid) { var list = AddAviserTilGrid(bladid);
dgMediePlanlinjer.DataSource = list; Console.WriteLine(list[0]); MessageBox.Show("Hej August" + list[0].BogholderiEmails); }
private List<AviserTilGrid> AddAviserTilGrid(List<int> bladid) { foreach (int i in bladid) { var res = aviserDao.GetAllUgeAvisTilGrid(i, System.DateTime.Now.Year - 1, 1); aktiveUgeaviserMeds.Add(res); } return aktiveUgeaviserMeds; }
private int findMediePlanNr() { return mediePlanDao.GetLatestMedienr().Item2 ; }
}}
And the XamDataGrid looks like this
<igWPF:XamDataGrid HorizontalAlignment="Left" Grid.Row="7" VerticalAlignment="Top" Height="518" Width="1764" Grid.ColumnSpan="12" Grid.RowSpan="3" Name="dgMediePlanlinjer" BindToSampleData="False" GroupByAreaLocation="AboveDataArea" Margin="37,0,0,0"> <igWPF:XamDataGrid.FieldSettings > <igWPF:FieldSettings AllowCrossFieldRecordFiltering="true" AllowRecordFiltering="true" CellClickAction="SelectCell" /> </igWPF:XamDataGrid.FieldSettings>
<igWPF:XamDataGrid.FieldLayouts>
<igWPF:FieldLayout>
<igWPF:FieldLayout.Settings> <igWPF:FieldLayoutSettings AutoArrangeCells="Never" AutoGenerateFields="False"/> </igWPF:FieldLayout.Settings>
<igWPF:TextField Name="Adresse" Label="navn" Visibility="Visible"/>
</igWPF:FieldLayout>
</igWPF:XamDataGrid.FieldLayouts>