tags:

views:

200

answers:

1

I'm using a Datagrid from the WPFtoolkit and am running into a problem with the RowDetailsTemplate.

My RowDetailsTemplate contains 3 items: 2 Rich Text Boxes and a button. What I would like to have happen is the button stay docked to the right edge of the window and the two rich text boxes expand to fill the rest of the space. The problem I'm having is that if I dock the button to the right of the window, when I enlarge the window the button moves correctly and stays on the outside edge, but if I shrink the window back it doesn't shrink and keeps the same spacing. This causes it to be located outside the window and not visible. Is this the expected behavior? If anyone knows a workaround or a solution to setup the whole details template as I described I would appreciate some advice.

Relevant code:

<toolkit:DataGrid.RowDetailsTemplate>
    <DataTemplate>
<DockPanel Width="Auto">
    <DockPanel DockPanel.Dock="Right">
        <Button Height="50" Width="75" Margin="5 5 0 5" DockPanel.Dock="Right">
            <Image Source="Resources/ArrowOutOfBox.bmp" />
        </Button>
    </DockPanel>
    <StackPanel Margin="20 0 20 0" Orientation="Horizontal" HorizontalAlignment="Left" DockPanel.Dock="Left">
        <StackPanel>
            <ToolBar>
                <ToggleButton MinWidth="20" Command="EditingCommands.ToggleBold" CommandTarget="{Binding ElementName=rtbNewComment}" TextBlock.FontWeight="Bold" Content="B" />
                <ToggleButton MinWidth="20" Command="EditingCommands.ToggleItalic" CommandTarget="{Binding ElementName=rtbNewComment}" TextBlock.FontStyle="Italic" Content="I" />
                <ToggleButton MinWidth="20" Command="EditingCommands.ToggleUnderline" CommandTarget="{Binding ElementName=rtbNewComment}">
                    <TextBlock TextDecorations="Underline">U</TextBlock>
                </ToggleButton>
            </ToolBar>
            <RichTextBox 
                                    x:Name="rtbNewComment"
                                    Height="100"
                                    Margin="5 5 0 5"
                                    FlowDirection="LeftToRight" 
                                    VerticalScrollBarVisibility="Auto"
                                    IsReadOnly="False" 
                                    SpellCheck.IsEnabled="true" 
                                    >
            </RichTextBox>
        </StackPanel>
        <StackPanel>
            <RichTextBox 
                                    x:Name="rtbCommentHistory"
                                    Height="125"
                                    Margin="5 5 0 5"
                                    FlowDirection="LeftToRight" 
                                    VerticalScrollBarVisibility="Auto"
                                    IsReadOnly="True" 
                                    SpellCheck.IsEnabled="true" 
                                    >
                <RichTextBox.Resources>
                    <Style TargetType="{x:Type Paragraph}">
                        <Setter Property="Margin" Value="0" />
                    </Style>
                </RichTextBox.Resources>
            </RichTextBox>
        </StackPanel>
    </StackPanel>

</DockPanel>
</DataTemplate>
</toolkit:DataGrid.RowDetailsTemplate>
A: 

Turns out what happens is the DockPanel in the DetailsTemplate was trying to center itself, but center is was calculating would go up but not down. By setting HorizontalAlignment="Left" it fixed the problem. I would still like a way to make all items resize proportional to their current sizes to fill the box, but no luck so far.

Stephan