Welcome to the Xceed Community | Help
Community Search  
More Search Options

Field binding error using CardTitleTemplate on CompactCardView / CardView

Sort Posts: Previous Next
  •  07-10-2009, 5:53 AM Post no. 22447

    Field binding error using CardTitleTemplate on CompactCardView / CardView

    I have the following DataGrid defined in my XAML:

    <xcdg:DataGridControl>
      <xcdg:DataGridControl.Columns>
        <xcdg:Column FieldName="ContactName" />
      </xcdg:DataGridControl.Columns>
      <xcdg:DataGridControl.View>
        <xcdg:CompactCardView>
          <xcdg:CompactCardView.CardTitleTemplate>
            <DataTemplate>
              <TextBlock Text="{Binding [ContactName]}" />
            </DataTemplate>
          </xcdg:CompactCardView.CardTitleTemplate>
        </xcdg:CompactCardView>
      </xcdg:DataGridControl.View>
    </xcdg:DataGridControl>

    At run-time, I expect the value in the ContactName field of each record to also appear in the card title, but I am getting the following error showing in my Output window:

    System.Windows.Data Error: 39 : BindingExpression path error: '[]' property not found on 'object' ''ContactDetails' (HashCode=55223077)'. BindingExpression:Path=[ContactName]; DataItem='ContactDetails' (HashCode=55223077); target element is 'TextBlock' (Name=''); target property is 'Text' (type 'String')

    What am I doing wrong here?

    Thanks for any help,
    Jason


    Associate, .NET Development
    Morgan Stanley, UK
  •  07-10-2009, 7:54 AM Post no. 22452 in reply to 22447

    Re: Field binding error using CardTitleTemplate on CompactCardView / CardView

    If you remove the brackets around "ContactName" does the binding error persist?
    Senior Technical Writer
    - Xceed Software

    In three words I can sum up everything I've learned about life: it goes on.
  •  07-10-2009, 11:01 AM Post no. 22458 in reply to 22452

    Re: Field binding error using CardTitleTemplate on CompactCardView / CardView

    Thanks, that fixed it!  I used the example in the CardView sample project which has the following code in it:

          <DataTemplate x:Key="cardTitleDataTemplate">
             <StackPanel Orientation="Horizontal">
                <TextBlock Text="{Binding [LastName]}" />
                <TextBlock Text=", " />
                <TextBlock Text="{Binding [FirstName]}" />
             </StackPanel>
          </DataTemplate>

    But that must be using it in a different way...


    Associate, .NET Development
    Morgan Stanley, UK
View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2011 Xceed Software Inc.