Zdravím, mám takový problém s DataBindingem ve WPF. Mám ObservableCollection<T> a chtěl bych, aby se mi obsah zobrazil v ListView, ale neustále se mi to nedaří. Neustále se mi ukazují chyby " The resource "udalostiPrintUI" could not be resolved." a Error 2 Inconsistent accessibility: property type 'System.Collections.ObjectModel.ObservableCollection<DynamicPulse_v2._3.UdalostiType>' is less accessible than property 'DynamicPulse_v2._3.Udalosti.udalostiPrintUI' C:\Users\kejhy\documents\visual studio 2012\Projects\DynamicPulse_v2.3\DynamicPulse_v2.3\Udalosti.xaml.cs 67 51 DynamicPulse_v2.3
public partial class Udalosti:Window
{
ObservableCollection<UdalostiType> udalostiPrint = new ObservableCollection<UdalostiType>();
public Udalosti()
{
InitializeComponent();
udalostiPrint.Add(new UdalostiType("Angličtina", "Writing a postcard", DateTime.Now));
udalostiPrint.Add(new UdalostiType("Fyzika", "Gravitační zákony", DateTime.Now));
}
private void Udalosti_Loaded_1(object sender, RoutedEventArgs e)
{
try
{
using (XmlReader cteni = XmlReader.Create("udalosti.xml"))
{
string predmet = "";
string latka = "";
DateTime datum = new DateTime();
while (cteni.Read())
{
if (cteni.NodeType == XmlNodeType.Element)
{
predmet = cteni.Name;
latka = cteni.GetAttribute("latkaXML");
datum = DateTime.Parse(cteni.GetAttribute("datumXML"));
}
else if (cteni.NodeType == XmlNodeType.EndElement)
{
_vsechnyUdalosti.Add(new UdalostiType(predmet, latka, datum));
udalostiPrint.Add(new UdalostiType(predmet, latka, datum));
}
}
}
}
catch (FileNotFoundException)
{
}
}
public ObservableCollection<UdalostiType> udalostiPrintUI { get { return udalostiPrint; } }
a XAML kód
<ListView x:Name="UIUdalostiPrehled" Width="250" Margin="17,30,17,60" ItemsSource="{Binding Source={StaticResource udalostiPrintUI}}">
<ListView.View>
<GridView>
<GridViewColumn DisplayMemberBinding="{Binding Path=PredmetUI}" x:Name="UIListViewPredmet" Header="Predmet" Width="80"></GridViewColumn>
<GridViewColumn DisplayMemberBinding="{Binding Path=LatkaUI}" x:Name="UIListViewLatka" Header="Látka" Width="80"></GridViewColumn>
<GridViewColumn DisplayMemberBinding="{Binding Path=DatumUI}" x:Name="UIListViewDatum" Header="Datum" Width="80"></GridViewColumn>
</GridView>
</ListView.View>
</ListView>
Nevíte čím to je ??
Děkuji za odpoveď