将枚举System.IO.WatcherChangeTypes绑定到ComboBox项源

时间:2019-05-07 12:40:59

标签: wpf xaml enums binding filesystemwatcher

我正在尝试将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

0 个答案:

没有答案