Embedding a combo box in a RichTextBox
UPDATE (January 2007):
As of the released version of WPF/.NET 3.0, this functionality no longer works at all if you want the control to actually be enabled -- and appears to be intentional/as expected. Several Microsoft employees have stated as much in forum posts.
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=389348&SiteID=1
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=716043&SiteID=1 (look for a post by Prajakta Joshi)
I'm disappointed to say the least that this wasn't included in the final V1 release, as it's something the company I work for would absolutely have used. I hope it returns in V2.
Someone wrote me yesterday asking how I'd gotten a combo box to be embedded successfully in a RichTextBox in WinFX. Since I last discussed this, several WinFX CTPs have come and gone, so I thought I'd post a slightly updated sample. The only real difference is that I changed the FlowDocument IsEnabled property to "True."
Oddly, even though this works on my system just fine, it doesn't work on his. Does it work on yours?
xml version="1.0" encoding="utf-8"?>
<Grid
xmlns="http://schemas.microsoft.com/winfx/avalon/2005"
xmlns:x="http://schemas.microsoft.com/winfx/xaml/2005"
xmlns:c="http://schemas.microsoft.com/winfx/markup-compatibility/2005"
Background="#FFFFFFFF"
x:Name="DocumentRoot"
Width="640" Height="480">
<ColumnDefinition/>
<RowDefinition/>
<RichTextBox x:Name="myRichTextBox" Margin="88,98,210,126" Width="Auto" Height="Auto" RenderTransformOrigin="0.5,0.5">
<FlowDocument AllowDrop="True" IsEnabled="True" IsHyphenationEnabled="False">
<Paragraph>
<Run>This is so cool. A combo box floating in the text region of the rich text control.< span>Run>
<InlineUIContainer>
<ComboBox
IsSynchronizedWithCurrentItem="True"
x:Name="embeddedCombo"
RenderTransformOrigin="0.5,0.5"
Width="150" Height="23" IsEnabled="True" />
< span>InlineUIContainer>
< span>Paragraph>
< span>FlowDocument>
< span>RichTextBox>
< span>Grid>