Home Forums WPF controls Xceed DataGrid for WPF Text not displayed in cells

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #22855 |

    I am having trouble with the datagrid cells all appearing blank.

    I have tried using styles to change the background and foreground colours, and although the background colour changes I still can’t get text to show up. When I check cell values through visual studio debugging, they do have the correct data (which is unbound). When I select a row, the whole row changes to the ‘CurrentBackground’ colour; I still can’t see any text.

    It is as if all of the cells are blank but hold the correct data value.

    Here is an example of how I get the data into the table using hardcoded values for a two column table:

    dgRes.Items.Add(new object[] {
    “str1”,
    “str2”});

    Thankyou for your time.

    Imported from legacy forums. Posted by Andy (had 3363 views)

    Xceed Support
    Member
    Post count: 5658

    Can you provide the DataGridControl initialization code (or xaml)?

    Imported from legacy forums. Posted by Marcus [Xceed] (had 186 views)

    User (Old forums)
    Member
    Post count: 23064

    Here is the user control that the datagrid is embedded in. When the application runs, the main window sets its ‘Content’ property to this control (which so far has worked well).

    <UserControl
    xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation&#8221;
    xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml&#8221;
    xmlns:Custom=”http://schemas.xceed.com/wpf/xaml/datagrid&#8221;
    xmlns:d=”http://schemas.microsoft.com/expression/blend/2006&#8243; xmlns:mc=”http://schemas.openxmlformats.org/markup-compatibility/2006&#8243; mc:Ignorable=”d”
    x:Class=”Testbed.DatagridTestForm”
    x:Name=”UserControl”
    Focusable=”false”>

    <Grid x:Name=”grid”>
    <Grid.ColumnDefinitions>
    <ColumnDefinition Width=”0.1*”/>
    <ColumnDefinition Width=”0.8*”/>
    <ColumnDefinition Width=”0.1*”/>
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
    <RowDefinition/>
    <RowDefinition/>
    </Grid.RowDefinitions>

    <Custom:DataGridControl Margin=”0,20,0,10″ x:Name=”dgRes” Grid.Column=”1″ SelectionMode=”Single” ReadOnly=”True” NavigationBehavior=”RowOnly” >

    <Custom:DataGridControl.Columns>
    <Custom:Column FieldName=”FirstCol” Title=”MyCol1″/>
    <Custom:Column FieldName=”SecondCol” Title=”MyCol2″/>
    </Custom:DataGridControl.Columns>
    </Custom:DataGridControl>

    … [a layout grid with buttons sits in the 2nd row of the main layout grid here]

    </Grid>
    </UserControl>

    Imported from legacy forums. Posted by Andy (had 330 views)

    Xceed Support
    Member
    Post count: 5658

    When working with Unbound Data, you need to specify a DisplayMemberBinding on the columns… In your case, the display member bindings should be:

    <Custom:Column FieldName=”FirstCol” Title=”MyCol1″ DisplayMemberBinding=”{Binding Path=[0], Mode=TwoWay}”/>
    <Custom:Column FieldName=”SecondCol” Title=”MyCol2″ DisplayMemberBinding=”{Binding Path=[1], Mode=TwoWay}”/>

    Imported from legacy forums. Posted by Marcus [Xceed] (had 225 views)

    User (Old forums)
    Member
    Post count: 23064

    Thankyou, works like a charm.

    Imported from legacy forums. Posted by Andy (had 4502 views)

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.