tags:

views:

19

answers:

1

Hello,

Do You know any good example or any good hint on how to make user controll that has defined text with blank areas which has to be filled out to complete excercise. Then submit answer and check (what was written in blanks and check if its good or not).

What Is the best way of doing that in order to be quite generic for example user (teacher) marks text which should be hidden.

It may be in WPF or WinForms (whatever is better for that).

thanks for any hint on how to begin and what to use.

A: 

I think I would have a (WPF) UserControl derived class that can take a custom formatted string (or xml) that contains the text and the placeholders to display:

myUserControl.DisplayContent="Rome was built in #numberofdays# day(s). The first mayor of Rome was #mayorofrome#."

The UserControl parses that string and builds the UI consisting of TextBlocks (the static text) and TextBoxes (the input controls).

Additionally the UserControl has a Property of Type Dictionary<string,string> that contain the strings entered by the user (keyed by placeholder string):

Console.WriteLine(myUserControl.Result["numberofdays"]);
Console.WriteLine(myUserControl.Result["mayorofrome"]);

This dictionary will be filled by the UserControl as the user enters the texts.

bitbonk