开发者

How make a view for editing different models' settings?

This is an example of my general problem:

I have different implementations of ITextSearcher to search for something. Each implementation has different settings that can be edited by the user. So I can't make a general editable view for the implementations (because the settings can't be abstracted by an interface).

I have developed a simple library that helps in this situations. It allows to declaratively tag a class and it's properties with view information. A view generator uses this information to render the class. This is an example:

[Editable]
internal class TermSearcher : ITextSearcher
开发者_开发百科{
    [Editable(Name="Search Expression", Order = 1)]
    public string Expression
    {...}

    [Editable(Name="Match Similar Characters", Order = 2)]
    public bool MatchSimilarChars
    {...}

    // rest of the implementation ...
}

Is there a better solution?


Yes. In WPF or Silverlight you can create a DataTemplate for the various instantiations of ITextSearcher. You can then use a DataTemplateSelector to pick the appropriate DataTemplate given an instance of an ITextSearcher

Since you tagged the post with MVVM I'm assuming you are using WPF

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜