Share via


Blogging Code and Xml From Word 2007

Pat Long has been trying to post xml and code samples to his nice new blog. It appears he's having problems. So, I thought I'd give it a go and prove to him that Word 2007 does an excellent job of posting both.

Here is some sample xml...

<Grid
xmlns="https://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http:"//schemas.microsoft.com/winfx/2006/xaml Height="300"Width="300"><StackPanel
Background="Green">

 

<ToggleButton
Content="Enable/Disable"
Margin="5"
Name="EnableDisableButton"
IsChecked="True">

</ToggleButton>

 

<Border
BorderThickness="0.5"
BorderBrush="AntiqueWhite"
Margin="5">

<Grid
Margin="5">

<Grid.ColumnDefinitions>

<ColumnDefinition/>

<ColumnDefinition/>

</Grid.ColumnDefinitions>

<Grid.RowDefinitions>

<RowDefinition/>

<RowDefinition/>

</Grid.RowDefinitions>

<Label
Content="First Name"
HorizontalAlignment="Right"
Grid.Row="0"
Grid.Column="0"/>

<TextBox
Grid.Row="0"
Grid.Column="1"
IsEnabled="{Binding Path=IsChecked, ElementName=EnableDisableButton}"/>

<Label
Content="Last Name"
HorizontalAlignment="Right"
Grid.Row="1"
Grid.Column="0" />

<TextBox
Grid.Row="1"
Grid.Column="1"
IsEnabled="{Binding Path=IsChecked, ElementName=EnableDisableButton}"/>

</Grid>

</Border>

</StackPanel>

</Grid>

And here is some sample code...

using System;

using System.Collections;

 

public
delegate
int Transformer(int input);

 

public
class Simple : IEnumerable {

 

private
int data;

 

public Simple(int data) {

this.data = data;

}

 

public
override
string ToString() {

return
String.Format("Simple<{0}>", data);

}

 

public
IEnumerator GetEnumerator() {

for (int i = 0; i < data; i ++) {

yield
return
new Simple(i);

}

}

 

public
int Transform(Transformer t) {

return t(data);

}

 

public
static Simple operator +(Simple a, Simple b) {

return
new Simple(a.data + b.data);

}

}

Comments

  • Anonymous
    September 24, 2006
    The comment has been removed
  • Anonymous
    September 24, 2006
    Yeah. You're right John. It's not good. And the RSS feed is worse. I'll look into ways of trying to get Word 2007 to do the right thing and post any findings back here.