我正在尝试将system.io.WatcherChangeTypes
枚举绑定到组合框的itemsource,但是XAML编辑器似乎无法在命名空间中找到该枚举。我猜我正在忽略一些简单的东西,但希望有人能帮助我。
样本代码:
<Window
x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:EnumBindingTest"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:sysIO="clr-namespace:System.IO;assembly=WindowsBase"
Title="MainWindow"
Width="200"
Height="100"
mc:Ignorable="d">
<Grid>
<!-- This Works -->
<ComboBox
Width="120"
HorizontalAlignment="Center"
VerticalAlignment="Top"
ItemsSource="{Binding Source={x:Static Fonts.SystemFontFamilies}}" />
<!-- This Doesn't Works -->
<ComboBox
Width="120"
HorizontalAlignment="Center"
VerticalAlignment="Bottom"
ItemsSource="{Binding Source={x:Static sysIO:WatcherChangeTypes}}" />
</Grid>
</Window>
我知道WatcherChangeTypes
在名称空间System.IO中,请参阅:https://docs.microsoft.com/en-us/dotnet/api/system.io.watcherchangetypes?view=netframework-4.8