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

Set the width of UserControl to Width of RadGridview Row

3 Answers 112 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Dharmavaram
Top achievements
Rank 1
Dharmavaram asked on 18 May 2017, 12:11 PM

Hi 

Iam using GridViewToggleRowDetailsColumn ,in that column I am showing one user control. I tried to set the width of usercontrol to the width of the row but it is not working.

 

 <MyUserControl:MyControl Width="{Binding Width,RelativeSource={RelativeSource AncestorType=telerik:GridViewRow}}" />

 

I didn't Keep any width property for my usercontrol.

Please suggest how can I achieve?

 

3 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 23 May 2017, 10:12 AM
Hello Dharmavaram,

In order to achieve this, you can bind the Width of the UserControl to the ActualWidth property of GridViewRow instead. For an explanation of the difference between the two properties, please, check out the What is the difference between Width and ActualWidth in WPF StackOverflow thread.

Can you please give the approach a try?

Best Regards,
Stefan X1
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Dharmavaram
Top achievements
Rank 1
answered on 23 May 2017, 10:50 AM

Hi Stefan,

I tried with Actual Width also but it is not working.I have attached image how it is coming once I change Width to Actual Width.I am keeping my usercontrol insdie the RadGridView Detailer Column

 

0
Stefan
Telerik team
answered on 26 May 2017, 09:17 AM
Hello Dharmavaram,

Though I am not completely sure why the Width of the UserControl is not set in this scenario, have you considered using the LoadingRowDetails event of RadGridView? The event arguments provide the Row property and you should be able to get its ActualWidth property value. Then, by using the approach demonstrated in the Find a control in RowDetailsTemplate topic you should be able to set the needed Width of the UserControl. A similar approach is discussed in the RadGridView stretch width of RowDetails forum thread. It is for Silverlight, but the same approach is applicable for the WPF RadGridView as well.

Would such an approach be feasible for you?

Regards,
Stefan X1
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
GridView
Asked by
Dharmavaram
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Dharmavaram
Top achievements
Rank 1
Share this question
or