Click here to Skip to main content
       

Silverlight / WPF

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionWPF DataGrid Not SHowing Any DatamemberKevin Marois20 Sep '12 - 11:30 
When I set AutoGenerateColumns = false, then I see no data. I see the data when AutoGenerateColumns = True. Here's my grid:
 
<DataGrid Grid.Row="1"
            Grid.Column="0"
            Grid.ColumnSpan="2"
            Margin="5"
            ItemsSource="{Binding AccountItems}"
            SelectedItem="{Binding SelectedAccountItem}"
            AutoGenerateColumns="True">
    <DataGrid.Columns>
        <DataGridTemplateColumn Header="Date" 
                                Width="SizeToCells" 
                                IsReadOnly="True">
            <DataGridTemplateColumn.CellTemplate>
                <DataTemplate>
                    <Image Source="{Binding DisplayDate}" />
                </DataTemplate>
            </DataGridTemplateColumn.CellTemplate>
        </DataGridTemplateColumn>
        <DataGridTemplateColumn Header="Memo 1" 
                                Width="SizeToCells" 
                                IsReadOnly="True">
            <DataGridTemplateColumn.CellTemplate>
                <DataTemplate>
                    <Image Source="{Binding Memo1}" />
                </DataTemplate>
            </DataGridTemplateColumn.CellTemplate>
        </DataGridTemplateColumn>
 
        <DataGridTemplateColumn Header="Memo 2" 
                                Width="SizeToCells" 
                                IsReadOnly="True">
            <DataGridTemplateColumn.CellTemplate>
                <DataTemplate>
                    <Image Source="{Binding Memo2}" />
                </DataTemplate>
            </DataGridTemplateColumn.CellTemplate>
        </DataGridTemplateColumn>
        <DataGridTemplateColumn Header="Debit" 
                                Width="SizeToCells" 
                                IsReadOnly="True">
            <DataGridTemplateColumn.CellTemplate>
                <DataTemplate>
                    <Image Source="{Binding Debit}" />
                </DataTemplate>
            </DataGridTemplateColumn.CellTemplate>
        </DataGridTemplateColumn>
        <DataGridTemplateColumn Header="Credit" 
                                Width="SizeToCells" 
                                IsReadOnly="True">
            <DataGridTemplateColumn.CellTemplate>
                <DataTemplate>
                    <Image Source="{Binding Credit}" />
                </DataTemplate>
            </DataGridTemplateColumn.CellTemplate>
        </DataGridTemplateColumn>
        <DataGridTemplateColumn Header="Balance" 
                                Width="SizeToCells" 
                                IsReadOnly="True">
            <DataGridTemplateColumn.CellTemplate>
                <DataTemplate>
                    <Image Source="{Binding Balance}" />
                </DataTemplate>
            </DataGridTemplateColumn.CellTemplate>
        </DataGridTemplateColumn>
    </DataGrid.Columns>
</DataGrid>
 
What am I doing wrong here?
 
Thanks
If it's not broken, fix it until it is

GeneralRe: WPF DataGrid Not SHowing Any Data PinprotectorPete O'Hanlon20 Sep '12 - 11:59 
Kenneth Haugland wrote:
Windows Forms Designer

He's talking about WPF, not Windows Forms, and he's put what looks like well formed templates in there.

*pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

"Mind bleach! Send me mind bleach!" - Nagy Vilmos

CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

GeneralRe: WPF DataGrid Not SHowing Any Data PinmemberKenneth Haugland20 Sep '12 - 12:10 
Dang it... Sigh | :sigh:
AnswerRe: WPF DataGrid Not SHowing Any Data PinprotectorPete O'Hanlon20 Sep '12 - 12:01 
Hard to say from that - we only have half the picture here. Tell you what, what do you see if you change the DataGridTemplateColumns into DataGridTextColumns? What appears in the text? Is the source correct then?

*pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

"Mind bleach! Send me mind bleach!" - Nagy Vilmos

CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

GeneralRe: WPF DataGrid Not SHowing Any Data PinmemberKevin Marois20 Sep '12 - 13:23 
That did it. Thanks Pete
If it's not broken, fix it until it is

GeneralRe: WPF DataGrid Not SHowing Any Data PinprotectorPete O'Hanlon20 Sep '12 - 13:58 
Not a problem.

*pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

"Mind bleach! Send me mind bleach!" - Nagy Vilmos

CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   


Advertise | Privacy | Mobile
Web01 | 2.6.130523.1 | Last Updated 25 May 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid