[DevExpress Support Team: CLONED FROM T316264: FloatGroup.SizeToContent doesn't work when WindowsFormsHost is used as the root content]
Could you please try docking to the right hand side of Benchmark grid (as in the screenshot), then check/uncheck the +3's?
Thanks,
Thomas
How to size FloatPanel with XtraGrid located inside the WindowsFormsHost control
Answers approved by DevExpress Support
Hello,
To resolve this issue, I suggest you perform your sizing logic only when your LayoutPanel is floating. For example, you can create an additional bool property and use it as a flag in the OnDocked event handler. I've modified your sample project to demonstrate the main idea of this approach.
Thanks,
Kirill
Thomas, you can enable and disable the AutoWidth option depending on the current panel's state. What do you think?
Andrey
I'm not sure I follow that. Can you please post a sample or modify the spike attached?
Thanks,
-Thomas
Hi Thomas,
The simplest way to do so is to bind the FloatGroup.SizeToContent to DockItemState using a custom converter in the LayoutPanel style.
XAML<Style TargetType="{x:Type dxdo:LayoutPanel}">
...
<Setter Property="dxdo:FloatGroup.SizeToContent" Value="{Binding DockItemState, Mode=OneWay, RelativeSource={RelativeSource Self}, Converter={dxDockingSpike:StateToSizeToContentConverter}}" />
</Style>
C#public class StateToSizeToContentConverter : MarkupExtension, IValueConverter {
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {
var state = (DockItemState)value;
switch (state) {
case DockItemState.Floating: return SizeToContent.WidthAndHeight;
case DockItemState.Docked: return SizeToContent.Manual;
}
return value;
}
public override object ProvideValue(IServiceProvider serviceProvider) {
return this;
}
...
}
I've attached a modified sample.