English 中文(简体)
wpf datagrid footer layout
原标题:

My footer is currently composed of a label and an ItemsControl. It needs to be below 2 DataGrid controls that are similar in that they both contain a fixed width column for every day in the week and the end of it (which is what the ItemsControl in the footer has totals for).

I m trying to solve the alignment, which seems easiest to just right align the day columns. I thought I could use a DockPanel as a container and Dock=Right on the ItemsControl like below, but everything is starting on the left after the label.

<DockPanel x:Name="columnTotals" DockPanel.Dock="Bottom" >

    <Label ... DockPanel.Dock="Left" Width="Auto">Grand Totals</Label>

        <ItemsControl DockPanel.Dock="Right"
            ItemsSource="{Binding Path=TotalTimeViewModels, Mode=OneWay}">
            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <StackPanel Orientation="Horizontal"/>
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
        </ItemsControl>

    </DockPanel>

So my primary question in this post is: why doesn t the ItemsControl actually dock to the right of it s parent container (currently also a DockPanel)?

Cheers,
Berryl

The secondary and more complicated question is how to make a footer line up with DataGrid columns. My main thought to date has been to use the fact that the last columns are always the same and their width is fixed.

I can make things line up with a StackPanel using FlowDirection=RightToLeft and 8 children labels (as opposed to one ItemsControl), but this has the disadvantages of making the XAML bloated and requires the text to be RightToLeft to reverse the container flow - it s messy and confusing to look at.

I guess the footer also could be another DataGrid, but the columns wouldn t be the same so I d still have to solve the alignment by either working right to left as I m doing now, or figure out what the starting point of the day columns is both initially and after a resize (I do not know how to do that).

Again, thanks for reading this and Cheers,
Berryl

最佳回答

This code solves the alignment problem using a DockPanel:

<DockPanel LastChildFill="True" DockPanel.Dock="Bottom" >

    <ItemsControl DockPanel.Dock="Right" Width="Auto" ... />

    <Label ... Width="Auto">Grand Totals</Label>

</DockPanel>

Cheers,
Berryl

问题回答

暂无回答




相关问题
Silverlight Rich text box control

Our team decided that we need our own custom Rich text box control for Silverlight app we are developing. We looked at existing controls mentioned at A good rich text control for Silverlight but ...

Silverlight ImageBrush not rendering (with Bing Map Control)

I m trying to add an image to a Pushpin instance from the Silverlight Bing Map Control, but I can t seem to get it to render (the pushpin renders fine). This is probably a general WPF question rather ...

Silverlight OpenFileDialog DoEvents equivalent

I m processing large files after they are selected by the user. My code looks like the following: if (FileDialog.ShowDialog() == true) { // process really big file } This freezes up the UI so ...

list of controls with templates in silverlight

Does anyone know where to find a list of controls that you can set the template on in Silverlight? I ve wasted several hours now trying to create control templates only to find that the control doesn ...

Silverlight, Updating the UI during processing

I have a simple silverlight multifile upload application, and i want to provide the user with some feedback, right now its only in a test phase and i dont have the webservice. Somehow i cant get the ...

Silverlight 3 - FindName returns null

This looks a bug to me.. Using Silverlight 3 and i have a user control defined in XAML and trying to access the object during runtime returns a null. <Grid> <common:CommonGridEditPanel x:...

silverlight 3 collection binding

Someone please help me understand why this binding does not work... I have a class called SelectionManager with a property called dates which is populated by a WCF service. The property is an ...

热门标签