No rules exist that require you to match the chair rail in your dining room to the wooden trim around the room's window. However, matching the style, type and color of the chair rail to the window is ideal because it allows it to tie in with the room's decor. If your dining room's window trim is lightly stained red oak with a simple molding pattern, adopt a similar style for the chair rail.
If you don't want the chair rail to stand out and be overly noticeable, match it to the wall instead of the wooden trim around the windows in the room. If your dining room's walls are painted beige, use a thin, simple-looking strip of wood for the chair rail and paint in the same color. At a distance, it won't be evident, but it will still offer the protection you desire.
Some rooms have subtle wood trim around the windows. If you want to make the wood of your chair rail a focal point in the room, add wainscoting below it and paint or stain the wood in a color that suits the room. Wainscoting is a common pattern of styling the lower third of rooms. You place strips of wood vertically up to 32 to 36 inches high and finish the top with a chair rail. Some people use paneling in place of wainscoting capped by a chair rail.
Just as it's acceptable to tie the color and style of the chair rail in with the other wood in the room, you can also use the chair rail to create contrast. Adding too many styles to one room can create a chaotic look, but if the room's windows have little in the way of trim, paint the chair rail a strong color that complements the drapes or art on the wall.