jam*_*mes 2 c# data-binding wpf enums xaml
我有一个包含枚举的BatchInfoViewModel类:
namespace MyStuff.ViewModel
{
public class BatchInfoViewModel : ObservableObject
{
public enum TimeFrame
{
Today,
Last7days,
Last30days,
Last6months,
Last12months,
All
}
}
}
Run Code Online (Sandbox Code Playgroud)
和一个用户控件'BatchInfoView'使用BatchInfoViewModel,我试图将此视图中的组合框绑定到模型上的TimeFrame枚举,但我发现的每个资源都显示了我认为我正在使用的方法,但我在运行时一直收到Type not found例外.
<UserControl x:Class="MyStuff.View.BatchInfoView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:view="clr-namespace:MyStuff.View"
xmlns:viewModel="clr-namespace:MyStuff.ViewModel;assembly=MyStuff.ViewModel"
xmlns:sys="clr-namespace:System;assembly=mscorlib">
<UserControl.Resources>
<ObjectDataProvider x:Key="EnumDataProvider"
MethodName="GetValues"
ObjectType="{x:Type sys:Enum}">
<ObjectDataProvider.MethodParameters>
<!--None of these work at all, I'm lost :( I've tried variations of these: -->
<!--<viewModel:BatchInfoViewModel></viewModel:BatchInfoViewModel>
<x:Type TypeName="viewModel:TimeFrame"/>
<x:Type TypeName="BatchInfoViewModel:TimeFrame"/>-->
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
Run Code Online (Sandbox Code Playgroud)
它找不到类型并将抛出异常.
归档时间: |
|
查看次数: |
1507 次 |
最近记录: |