Bind control width in RowDetails to gridview column.actualwidth

7 posts, 0 answers
  1. Mikel
    Mikel avatar
    21 posts
    Member since:
    Feb 2014

    Posted 11 Apr Link to this post

    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!!

  2. Dilyan Traykov
    Admin
    Dilyan Traykov avatar
    368 posts

    Posted 12 Apr Link to this post

    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.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Mikel
    Mikel avatar
    21 posts
    Member since:
    Feb 2014

    Posted 13 Apr in reply to Dilyan Traykov Link to this post

    Hello,

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

    Thank you!

  5. Dilyan Traykov
    Admin
    Dilyan Traykov avatar
    368 posts

    Posted 14 Apr Link to this post

    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.
  6. Mikel
    Mikel avatar
    21 posts
    Member since:
    Feb 2014

    Posted 14 Apr in reply to Dilyan Traykov Link to this post

    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!

  7. Dilyan Traykov
    Admin
    Dilyan Traykov avatar
    368 posts

    Posted 18 Apr Link to this post

    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.
  8. Mikel
    Mikel avatar
    21 posts
    Member since:
    Feb 2014

    Posted 18 Apr in reply to Dilyan Traykov Link to this post

    Hi, 

    Ok, dont worry, that works :D

     

    Thank you!

Back to Top
UI for WPF is Visual Studio 2017 Ready