我得到了这个例外:
AppName.exe中出现未处理的win32异常
仅当我绑定到ComboBox
时才会发生这种情况
这是我的XAML:
<ContentDialog x:Name="BrowseBySourceDialog"
Grid.Column="1"
PrimaryButtonText="Accept" IsPrimaryButtonEnabled="False"
Opened="BrowseBySourceDialog_Opened">
<StackPanel Background="White">
<Border Background="DarkGreen" MinHeight="40"
MinWidth="300">
<TextBlock Text="Browse: By Source"
VerticalAlignment="Center"
Foreground="White"
TextAlignment="Center"
HorizontalAlignment="Center" />
</Border>
<StackPanel>
<ComboBox x:Name="BrowseBySourceComboBox"
PlaceholderText="Select Source"
Height="40"
Width="300"
ItemsSource="{x:Bind BrowseBySourceList, Mode=OneWay}"
DisplayMemberPath="Source">
<ComboBox.ItemTemplate>
<DataTemplate x:DataType="local:FeaturedResponseItem">
<TextBlock Text="{x:Bind key}"/>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
</StackPanel>
</StackPanel>
</ContentDialog>
仅当存在以下行时才会发生此异常:
<ComboBox.ItemTemplate>
<DataTemplate x:DataType="local:FeaturedResponseItem">
<TextBlock Text="{x:Bind key}"/>
</DataTemplate>
</ComboBox.ItemTemplate>
如果删除上面的行,组合框肯定是空的,但不会发生异常。绑定错了吗?
来源:
ObservableCollection<FeaturedResponseItem> BrowseBySourceList { get; set; } = new ObservableCollection<FeaturedResponseItem>();
型号:
public class FeaturedResponseItem
{
public string key { get; set; }
public string icon { get; set; }
public bool accessible { get; set; }
}
答案 0 :(得分:3)
您可以删除<TabControl>
<TabItem Header="ERP">
<ContentControl Name="ccERP" Background="#FFE5E5E5"
Content="{Binding DataContext.SelectedConnection.ERP.PluginInstance.UI, RelativeSource={RelativeSource AncestorType=Window}}"/>
</TabItem>
</TabControl>
或只是将// readFile.js
const fs = require('fs');
var readFile = function readFile(fileName){
return new Promise((resolve, reject)=>{
fs.readFile(fileName, {encoding: 'utf-8'}, (err, contents)=>{
if(err){
reject(err);
}
resolve(contents);
});
});
};
module.exports.readFile = readFile;
//play.js
const {readFile} = require('./readFile');
var getText = function getTextFromFile(){
readFile('readMe.txt').then((contents)=>{
return contents;
}).catch((err)=>{
console.log(err);
});
};
module.exports.getText = getText;
//someFile.js
const {getText} = require('./play.js');
var result = getText();
console.log(result);
全部删除,然后将DisplayMemberPath="Source"
更改为ItemTemplate
。