Sorry for very long title of question but I had no idea how to make it shorter.
I have SettingsView Window with content control:
<Window x:Class="IsoMan.UI.Settings.Views.SettingsView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="SettingsView" WindowStartupLocation="CenterOwner"
SizeToContent="WidthAndHeight">
<ContentControl Name="ContentControl"/>
</Window>
Here in code-behind I am setting content of ContentControl. Here I simplified it a lot, normally it is set dynamically through binding so I never now what type of UserControl is currently set as Content. (but always UserControl)
public partial class SettingsView : Window
{
public SettingsView()
{
InitializeComponent();
ContentControl.Content = new UserSettingsView();
}
}
Here is my UserSettingsView.xaml, the control that is a child of SettingsView:
<UserControl x:Class="IsoMan.UI.Settings.UserSettings.Views.UserSettingsView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
MinHeight="400" MinWidth="700">
<DataGrid ItemsSource="{Binding UsersList}" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" >
<DataGrid.Columns>
<DataGridTextColumn Header="Name" Binding="{Binding FirstName}" Width="*"/>
</DataGrid.Columns>
</DataGrid>
</UserControl>
And here is my problem.
I have Window SizeToContent set to WidthAndHeight, because I want it's size to adjust to child control size (in this case UserSettingsView).
UserSettingsView has MinWidth/MinHeight set as I want user to not be able to make it smaller (buttons/grid presentation). This control has grid with one column which width is "*". I want it to take all available space.
What happens now:
After showing SettingsView it's width is MAX width of my screen. I think that it is cased by the fact, that grid's column's width in UserSettingsView is set to "*".
What I want to achieve:
After showing SettingsView it's width should be MinWidth of UserSettingsView. Also, when user try to resize SettingsView window, child control UserSettingsView should be resized also.