2
我有一个类BatchInfoViewModel包含一个枚举:WPF数据绑定枚举
namespace MyStuff.ViewModel
{
public class BatchInfoViewModel : ObservableObject
{
public enum TimeFrame
{
Today,
Last7days,
Last30days,
Last6months,
Last12months,
All
}
}
}
和用户控制“BatchInfoView”使用一个BatchInfoViewModel和我想要一个组合框在该视图绑定,给时间表枚举模型,但是我找到的每个资源都显示了我认为是我正在使用的方法,但是我在运行时不断发现Type未找到异常。
<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>
它无法找到类型并会抛出异常。
配售枚举在命名空间中,任何类之外的地区的车票。谢谢 ! – cjsmith
@cjsmith:很高兴帮助,只是测试了我以前的建议,但它不适用于此。 –