Home Forums WPF controls Xceed DataGrid for WPF Sharing a row between two panes

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

    I am looking for an elegant way to have master/details behaviour, when master is a grid and details is a card view showing current row. Grid is read-only and binded to the DataTable.

    Thanks in advance,

    Vladimir

    Imported from legacy forums. Posted by Vladimir (had 7195 views)

    User (Old forums)
    Member
    Post count: 23064

    Are the master and the slaves in two differents controls?

    Imported from legacy forums. Posted by Tanguy (had 573 views)

    User (Old forums)
    Member
    Post count: 23064

    Yes, although I am not sure it’s wise to implement Details pane as a Card View – it might be too heavy. I’m just playing with options. It doesn’t look like a good WPF design to start copying fields via code…

    Imported from legacy forums. Posted by Vladimir (had 348 views)

    Xceed Support
    Member
    Post count: 5658

    If I understood correctly, what you are trying to achieve is something like this?

    <code>
    <StackPanel>
    <DataGridControl x:Name=”master” ItemsSource=”{Binding Source={x:Static Application.Current},Path=Employees}”/>

    <DataGridControl x:Name=”detail” ItemsSource=”{Binding ElementName=master, Path=CurrentItem.EmployeesOrders }” />

    </StackPanel>
    </code>

    This shows a first grid, which lists all the employees present in the Employees table. Then, the second grid is bound to the master grid CurrentItem, and we expand the “EmployeesOrders” relation ( a property descriptor is present automatically on a DataRowView item for each relation).

    Then you can customize the look of any of the 2 grids.

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

    User (Old forums)
    Member
    Post count: 23064

    Okay.
    If you have separated controls, you can Bind data between two controls by using the “ElementName” Property of the Binding Class.

    Here is a small example of Data Binding between two different controls in WPF
    <StackPanel>
    <Slider Name =”MySlider” Maximum =”100″/>
    <TextBlock Name=”MyTextBlock” Text =”{Binding ElementName=MySlider, Path=Value}”/>
    </StackPanel>

    Doing it programmaticaly will be done like this :
    Binding binding = new Binding(“Value”);
    binding.ElementName = “MySlider”;
    MyTextBlock.SetBinding(TextBlock.TextProperty, binding);

    I think you could bind your two controls with something like that :
    Binding binding = new Binding(“SelectedItem”);
    binding.ElementName = “MyGridThatContainsAllTheData”;
    // This will define your data grid as the source of the binding, retrieving the SelectedItemProperty.

    MyCardViewGrid.SetBinding(DataGridControl.ItemsSourceProperty, binding);
    // This will define the items source of your cardview as the target of the binding.

    Hope this helps…

    Imported from legacy forums. Posted by Tanguy (had 602 views)

    User (Old forums)
    Member
    Post count: 23064

    Excuse me for this double usage post 15 minutes too late 😛

    Imported from legacy forums. Posted by Tanguy (had 528 views)

    Xceed Support
    Member
    Post count: 5658

    Never be sorry for participating to the community…

    Responding to the forums whenever you know/can is what will make this “community supported” control possible for everybody…

    Remember that it will be times when neither me or Pascal will be in a situation where we are capable of answering.

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

    User (Old forums)
    Member
    Post count: 23064

    Thanks to all, binding works. I wonder what are the “bindable” properties in Grid control. From some reason just binding to SelectedItems works properly, both CurrentItem & SelectedItem return UpdateTargetError.

    Imported from legacy forums. Posted by Vladimir (had 413 views)

    Xceed Support
    Member
    Post count: 5658

    Hmmm, can you provide the code you used that caused the “UpdateTargetError” ?

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

    User (Old forums)
    Member
    Post count: 23064

    //It works with SelectedItems

    DataGridControl grid = (DataGridControl)sender;
    BindingExpressionBase bp;
    if (grid.SelectedItems != null)
    {
    Binding binding = new Binding(“SelectedItems”);
    binding.Source = grid;

    bp = CardPreview.SetBinding(DataGridControl.ItemsSourceProperty, binding);
    }

    //Both SelectedItem & CurrentItem return bp.Status = UpdateTargetError

    DataGridControl grid = (DataGridControl)sender;
    BindingExpressionBase bp;
    if (grid.SelectedItems != null)
    {
    Binding binding = new Binding(“SelectedItem”);
    binding.Source = grid;

    bp = CardPreview.SetBinding(DataGridControl.ItemsSourceProperty, binding);
    }

    Imported from legacy forums. Posted by Vladimir (had 446 views)

    Xceed Support
    Member
    Post count: 5658

    Just to make sure of something, if you leave the binding in place (even though there is the “UpdateTargerError” ) and you select something in the “master grid”, is the Card preview grid refreshed?

    My point is that initially, the value of SelectedItem and CurrentItem is null, and probably that its the reason why you see the error… (in comparison, the SelectedItems property is never null).

    Let me know!

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

    User (Old forums)
    Member
    Post count: 23064

    No, it’s not null. Sorry for typo in cut & paste, but not null validation was addressed SelectedItem/CurrentItem correspondingly. Not speaking about debugger…

    Imported from legacy forums. Posted by Vladimir (had 8464 views)

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