イムは、私が負荷にXmlDataProviderは
<UserControl.Resources>
<XmlDataProvider x:Key="ReportData"
Source="../DesignData/report.xml"
XPath="Reports/Report" />
<DataTemplate x:Key="teamItemTemplate">
<Label Content="{Binding XPath=DocId}"/>
</DataTemplate>
</UserControl.Resources>
のような静的にXmlDataProviderを定義して、リストボックス内の文書を表示した場合、私は、XML文書
<?xml version="1.0" encoding="utf-8"?>
<Reports>
<Report Id="AAAAA-ABBB">
<DocId>10110001</DocId>
<DocName>ESP North Casing</DocName>
<DocType>2010-01-01</DocType>
<Status>1</Status>
<CreatedById>1</CreatedById>
<SiteId>1</SiteId>
<Language>1</Language>
<Updated>2011-01-01</Updated>
<Published>2011-01-01</Published>
<FilePath>c:\\reports\20011001.docx</FilePath>
</Report>
<Report Id="AAAAA-ABBC">
<DocId>10110002</DocId>
<DocName>ESP South Casing</DocName>
<DocType>2010-01-01</DocType>
<Status>1</Status>
<CreatedById>1</CreatedById>
<SiteId>1</SiteId>
<Language>1</Language>
<Updated>2011-01-01</Updated>
<Published>2011-01-01</Published>
<FilePath>c:\\reports\20011001.docx</FilePath>
</Report>
</Reports>
を持って
を困惑<ListBox x:Name="ReportListBox" Margin="60,12,114,64" DockPanel.Dock="Left"
ItemsSource="{Binding
Source={StaticResource ReportData}}"
ItemTemplate="{StaticResource teamItemTemplate}"
IsSynchronizedWithCurrentItem="True"
Visibility="Visible" SelectionMode="Single">
</ListBox>
私は見ることができます私はレポートをViewModelにし、プロパティにバインドするためのDataContextを設定した場合、私は私のviewmodel
private XmlDataProvider GetXMLReports()
{
string filePath = Directory.GetCurrentDirectory() + @"\Data\report.xml";
XmlDataProvider provider = new XmlDataProvider();
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.Load(filePath);
provider.Document = doc;
provider.XPath = "Reports/Report";
//Reports = _provider;
return provider;
}
public XmlDataProvider Reports
{
get { return _provider; }
set
{
_provider = value;
this.RaisePropertyChanged(() => this.Reports);
}
}
にコードや負荷にXmlDataProviderで同じことを行う場合
<ListBox x:Name="ReportListBox" Margin="60,12,114,64" DockPanel.Dock="Left"
ItemsSource="{Binding Path=Reports}"
ItemTemplate="{StaticResource teamItemTemplate}"
IsSynchronizedWithCurrentItem="True"
Visibility="Visible" SelectionMode="Single">
</ListBox>
何も示されていない
リストボックス内のデータ、 何か案は。
あなたが実際にコードにバインド()を呼び出していますか..? – MethodMan
私はviewmodelにusercontrolのdatacontextをバインドします。ブレークポイントを置くと、viewmodelがロードされていることがわかります。 – klashagelqvist
これはあなたの正確なコードですか?プロパティの割り当て/通知の内容が非常に乱雑であるため(レポート= _providerは重複していて、イベントはセッターで発生する必要があるため)、 – GazTheDestroyer