Limit WPF control size to a certain proportion / percentage of the parent control

23 Views Asked by At

I want to prevent these chat boxes from going over 50% of their parent (stackpanel)'s width

Like so: enter image description here

I am aware of this question but I do not understand the answer

Here's my XAML

            <ScrollViewer x:Name="MessageViewScroll" VerticalScrollBarVisibility="Auto" Panel.ZIndex="-1">
                <StackPanel Name="MessageView" Margin="0 100" VerticalAlignment="Bottom">
                    <local:UserControlMessageReceived HorizontalAlignment="Left" Loaded="UserControlMessageReceived_Loaded" Width="343" RenderTransformOrigin="0.5,0.5" Margin="2,0,0,0"/>
                    <local:UserControlMessageSent HorizontalAlignment="Right"/>
                </StackPanel>
            </ScrollViewer>

Any pointers?

0

There are 0 best solutions below