views:

57

answers:

2

I'm developing a Silverlight application where I want to simulate a console. There are a lot of ways to represent this - StackPannels, grid of TextBoxes, etc - and I was wondering what the bets fit would be?

Requirements:

  • Display an 80x20 grid that scales based on parent size
  • Be able to update an individual cell's character
  • Be able to set a cell's forground and background color
A: 

Grid filled with Textboxes?

But wait... 1600 Text boxes... I don't know what to do, sorry ((

Trickster
+1  A: 

Why would you use TextBox instead of TextBlock.

I think you should use 1 TextBlock and format the text like:

<TextBlock> 
    <Run FontWeight="Bold">Hello There.</Run> 
    <Run Foreground="Red">How are you?</Run> 
    <Run FontStyle="Italic">I am fine thanks!</Run> 
    <Run>漢字</Run> 
</TextBlock>

And start with setting 80*20 space keys. Then implement some algoritmen to find a specific character and fx to set its Foreground by clipping it out of the Run it is in and make some new Run objects.

And wire up some events to receive new keys. Or use one TextBlock where the keyboard pointer is.

You could also get inspiration from here: http://silverlight.net/content/samples/sl2/dlrconsole/index.html - you can download the code to the DLRConsole

lasseespeholt