小编Nov*_*kov的帖子

无法将enum绑定到组合框wpf mvvm

A已经阅读了很多关于将枚举绑定到组合框的方法.所以现在在.Net 4.5中它应该非常容易.但我的代码不起作用.真的不明白为什么.

XAML:

<Window x:Class="SmartTrader.Windows.SyncOfflineDataWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="SyncOfflineDataWindow" Height="300" Width="300">
<Grid>
    <StackPanel>
        <ComboBox ItemsSource="{Binding StrategyTypes}" SelectedItem="{Binding StrategyType}" />
        <Button Width="150" Margin="5" Padding="5" Click="Button_Click">Save</Button>
    </StackPanel>
</Grid>
Run Code Online (Sandbox Code Playgroud)

xaml.cs后端

namespace SmartTrader.Windows
{
    /// <summary>
    /// Interaction logic for SyncOfflineDataWindow.xaml
    /// </summary>
    public partial class SyncOfflineDataWindow : Window
    {
        public SyncOfflineDataWindow(IPosition position, ContractType type)
        {
            DataContext = new ObservablePosition(position);
            InitializeComponent();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {

        }
    }
}
Run Code Online (Sandbox Code Playgroud)

查看型号:

namespace SmartTrader.Entity
{
    public class ObservablePosition : NotifyPropertyChanged, IPosition
    {
        public IEnumerable<StrategyType> …
Run Code Online (Sandbox Code Playgroud)

c# wpf enums combobox mvvm

4
推荐指数
1
解决办法
5761
查看次数

向基类c#添加方法

是否可以向List等基类添加方法?或其他人?如果它具有MyClass类型,我真的需要将方法添加到泛型列表类.像这样: List<MyClass>.FindCoolStuff()List<MyClass>.SetValueByName()

谢谢

c# generics class base-class

1
推荐指数
1
解决办法
2393
查看次数

标签 统计

c# ×2

base-class ×1

class ×1

combobox ×1

enums ×1

generics ×1

mvvm ×1

wpf ×1