views:

31

answers:

1

Thats my code so far which does not work:

   <DockPanel  >        
            <Button Content="Start" Command="{Binding Path=FirstDateCommand}" />
            <Button Content="Back"  Command="{Binding Path=PreviousDateCommand}" />          
            <DatePicker Width="150"
                SelectedDate="{Binding Path=SelectedDate}"
                DisplayDateStart="{Binding Path=MinDate}" 
                DisplayDateEnd="{Binding Path=MaxDate}" SelectedDateFormat="Long" />
            <Button Content="Forward" Command="{Binding Path=NextDateCommand}" />
            <Button Content="End"     Command="{Binding Path=LastDateCommand}" />

            <Button Command="{Binding PrintCommand}" Content="Print Planner" />
            <Button Command="{Binding ToggleDocumentsCommand}" Content="Show Docs"  />
            <Button Command="{Binding MaterialExplorerShowCommand}" Content="Browse Docs" />
            <Button Command="{Binding LessonPlannerCommand}" Content="Edit Planner" />
            <TextBox Text="{Binding SearchText,Mode=TwoWay}" Width="50" />          
            <Button Command="{Binding FindAllCommand}" Content="Search"  />

            <DockPanel DockPanel.Dock="Right" HorizontalAlignment="Right">
                <TextBlock Text="class code:" VerticalAlignment="Center" />
                <ComboBox 
                ItemsSource="{Binding GroupViewModelList}" 
                Style="{StaticResource GroupViewModelStyle}"
                ItemTemplate="{StaticResource GroupViewModelItemTemplate}" 
                Width="100"/>
            </DockPanel>

        </DockPanel>

alt text

How can I set the 2 last controls on the image on the very right side?

UPDATE:

<Grid  Name="MainGrid">
        <Grid.RowDefinitions>
            <RowDefinition Height="40" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <Grid Margin="10,10,10,0"  Grid.Row="0" Name="ButtonBar">
            <StackPanel FocusManager.IsFocusScope="True" Orientation="Horizontal">               
                <ComboBox  
                        AlternationCount="2"
                        FontSize="16"
                        VerticalContentAlignment="Center"
                        Width="100" 
                        ItemContainerStyle="{StaticResource alternateColor}" 
                        ItemsSource="{Binding Source={x:Static Member=Fonts.SystemFontFamilies}}" x:Name="fontComboFast">
                    <ComboBox.ItemsPanel>
                        <ItemsPanelTemplate>
                            <VirtualizingStackPanel VirtualizingStackPanel.VirtualizationMode="Recycling" />
                        </ItemsPanelTemplate>
                    </ComboBox.ItemsPanel>                    
                    <ComboBox.ItemTemplate>
                        <DataTemplate>
                            <TextBlock Width="100" Text="{Binding}" FontFamily="{Binding }" />
                        </DataTemplate>
                    </ComboBox.ItemTemplate>
                </ComboBox>

                <!--<View:FormatButtonBar />-->
                <View:DateNavigatorView />
                <View:LessonPlannerView />
                <!--<View:TextFormatBarUC />-->
            </StackPanel>
        </Grid>

The 2 controls are in the LessonPlannerView (UserControl)

Inside the LessonPlannerView you find this code:

...
    <Grid >
        <DockPanel>              
            <Button Command="{Binding PrintCommand}" Content="Print Planner" />
            <Button Command="{Binding ToggleDocumentsCommand}" Content="Show Docs"  />
            <Button Command="{Binding MaterialExplorerShowCommand}" Content="Browse Docs" />
            <Button Command="{Binding LessonPlannerCommand}" Content="Edit Planner" />
            <TextBox Text="{Binding SearchText,Mode=TwoWay}" Width="50" />          
            <Button Command="{Binding FindAllCommand}" Content="Search"  />            
            <StackPanel x:Name="ClassCodeChooser" Orientation="Horizontal" DockPanel.Dock="Right" HorizontalAlignment="Right">
                <TextBlock Text="class code:" VerticalAlignment="Center" />
                <ComboBox ItemsSource="{Binding SchoolclassCodeList}"                 
                />
        </StackPanel>            
        </DockPanel>
    </Grid>
</UserControl>
A: 

That should be fine but you really don't need the nested DockPanel's. You could change the inner DockPanel to a horizontal StackPanel.

But the real problem is that your outer DockPanel doesn't seem to be expanding to the full width of its container. Set a Background on the outer DockPanel to give you a visual indication of why it isn't filling out its container.

In response to the comment thread below, adding the following example

<Grid Name="ButtonBar">
    <Grid.RowDefinitions>
        <RowDefinition Height="40" />
        <RowDefinition Height="*" />
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*" />
    </Grid.ColumnDefinitions>

    <DockPanel Grid.Row="0">
        <View:FormatButtonBar />  <!-- this will dock left -->
        <View:DateNavigatorView />  <!-- this will dock left -->
        <View:LessonPlannerView />  <!-- this will dock left -->
        <View:TextFormatBarUC /> <!-- this will fill -->
    </DockPanel>

</Grid>
Josh Einstein
yes the outer dockpanel is not stretching the whole width and I have no idea why. The whole ButtonBar is inside a UserControl to make it reuseable and I use it 2 times.
Lisa
I set HorizontalAlignment="Stretch" on the dockpanel, the parent grid, the parent usercontrol etc... its just stretching when I set a fixed width ?
Lisa
Can you show the whole tree up to the root Window or UserControl? The default HorizontalAlignment is Stretch so you don't need to explicitly set it.
Josh Einstein
Yes I can Josh, see the UPDATED Initial post :)
Lisa
It's kind of hard to make out since the code is broken up into several XAML snippets but I think your problem may be the horizontal StackPanel directly inside the Grid named ButtonBar. A horizontal StackPanel will always arrange its children to the left edge and children will never stretch. Try changing it to a DockPanel. Its children implicitly dock to the left and the last one will "fill" the remaining space.
Josh Einstein
great that worked!
Lisa