This is a migrated thread and some comments may be shown as answers.

Bind control width in RowDetails to gridview column.actualwidth

6 Answers 262 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Mikel
Top achievements
Rank 1
Mikel asked on 11 Apr 2016, 02:04 PM

Hi there.

 

How can I bind "custom control" width (that is in RowDetails of RadGridView) to an RadGridView column actualWidth?

Is that possible?

 

RadGridView

    |__ Column.ActualWidth

    |__ Row

          |__ RowDetails

                |__ CustomControl.Width(ActualWidth)

     

 

 

 

Thanks!!

6 Answers, 1 is accepted

Sort by
0
Dilyan Traykov
Telerik team
answered on 12 Apr 2016, 07:43 AM
Hello Mikel,

You can have a look at our Binding row details element width demo from our SDK Examples Browser, which can be downloaded here.

If that is not quite the behavior you're looking for, you can try handling RadGridView's DataLoading event like so:

public MainWindow()
{
    InitializeComponent();
    this.radGridView.DataLoading += RadGridView_DataLoading;
}
 
private void RadGridView_DataLoading(object sender, GridViewDataLoadingEventArgs e)
{
    GridViewDataControl dataControl = (GridViewDataControl)sender;
    if (dataControl.ParentRow != null)
    {
        dataControl.ShowGroupPanel = false;
        dataControl.AutoGenerateColumns = false;
 
        GridViewDataColumn column = new GridViewDataColumn();
        column.DataMemberBinding = new Binding("Name");
        column.Width = this.radGridView.Columns["Name"].ActualWidth;
        dataControl.Columns.Add(column);
    }
}

Let me know if this would work for you.

Regards,
Dilyan Traykov
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Mikel
Top achievements
Rank 1
answered on 13 Apr 2016, 08:04 AM

Hello,

It works using "Binding row details element width" but there is any way to do it in XAML.

Thank you!

0
Dilyan Traykov
Telerik team
answered on 14 Apr 2016, 11:17 AM
Hello Mikel,

As I did not quite understand from your last reply - did you try the approach from the SDK demo I sent you or the code snippet I provided?

If you are not satisfied with the code-behind approach from the code snippet, please refer to the SDK example I shared with you for a more MVVM-friendly approach for this scenario. Feel free to modify it to your liking.

Regards,
Dilyan Traykov
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Mikel
Top achievements
Rank 1
answered on 14 Apr 2016, 11:24 AM

Hi Dilyan,

 

I achieve my goal, making some modifications to demo "Binding row details element width", but I mean, if is it possible to do that binding via XAML?

 

Regards!

0
Dilyan Traykov
Telerik team
answered on 18 Apr 2016, 01:18 PM
Hello Mikel,

I'm afraid that this is the best approach I can offer.

Regards,
Dilyan Traykov
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Mikel
Top achievements
Rank 1
answered on 18 Apr 2016, 02:02 PM

Hi, 

Ok, dont worry, that works :D

 

Thank you!

Tags
GridView
Asked by
Mikel
Top achievements
Rank 1
Answers by
Dilyan Traykov
Telerik team
Mikel
Top achievements
Rank 1
Share this question
or