Hi All,
I am trying to responsives in WPF,i created user control in that user control i created my Design,That User control Put inside Main Window,here my problem is I am facing is that when I try to resize the main window holding the user control, the user control won't follow the parent window and not resize as well.
My User Control code
<UserControl x:Class="Class.View.UC1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
mc:Ignorable="d"
Height="600" Width="576" MinHeight="600" MinWidth="576">
<UserControl.Resources>
<viewmodel:ExtractInfoVM x:Key="vm"></viewmodel:ExtractInfoVM>
</UserControl.Resources>
<UserControl.DataContext>
<viewmodel:ExtractInfoVM></viewmodel:ExtractInfoVM>
</UserControl.DataContext>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="10" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="30" />
<RowDefinition Height="30" />
<RowDefinition Height="30" />
<RowDefinition Height="*" />
<RowDefinition Height="30" />
<RowDefinition Height="30" />
<RowDefinition Height="30" />
<RowDefinition Height="*" />
<RowDefinition Height="30" />
<RowDefinition Height="30" />
<RowDefinition Height="30" />
<RowDefinition Height="30" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Label Grid.Column="0" Grid.Row="0" MaxHeight="25" Content="Vendor:" Name="lblVendor"/>
<ComboBox ItemsSource="{Binding VendorList}" SelectedValue="{Binding SelectedVendor}" Grid.Column="1"
x:Name="cboVendor" Grid.ColumnSpan="4" />
<Label Grid.Column="0" Grid.Row="1" MaxHeight="25" Content="Server:" Name="lblServer"/>
<ComboBox Grid.Column="1" ItemsSource="{Binding Servers}"
SelectedValue="{Binding SelectedServer}"
x:Name="cboServer" Grid.ColumnSpan="4" Grid.Row="1" />
<Label Grid.Column="0" Grid.Row="2" MaxHeight="25" Content="DataBase:" Name="lblDataBase"/>
<ComboBox Grid.Column="1" ItemsSource="{Binding Databases}"
SelectedValue="{Binding SelectedDatabase}"
x:Name="cboDatabase" Grid.ColumnSpan="4" Grid.Row="2" />
<TextBox Grid.Column="0" Grid.ColumnSpan="3" Grid.Row="3" Background="#FFEFECCD" Text="{Binding AnalysisInfo}" Name="txtDesciptoin" ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto" TextWrapping="NoWrap" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" BorderThickness="2" />
<Border BorderBrush="Silver" BorderThickness="1" Grid.Column="3" Grid.Row="3" MaxHeight="120" Grid.ColumnSpan="2" >
<ListBox Name="lstReferenc"
SelectedItem="{Binding Path=SelectedGranularity,UpdateSourceTrigger=PropertyChanged}"
ItemsSource="{Binding Granularitylist, NotifyOnSourceUpdated=True}" SelectionMode="Multiple" Margin="103,8,9,8" IsEnabled="{Binding Path=AllPropertiesValid}" >
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding DetailValue}"/>
</DataTemplate>
</ListBox.ItemTemplate>
<ListBox.ItemContainerStyle>
<Style TargetType="{x:Type ListBoxItem}">
<Style.Triggers>
<DataTrigger Binding="{Binding IsSelected}" Value="True">
<Setter Property="Background" Value="Red" />
</DataTrigger>
</Style.Triggers>
<Setter Property="IsSelected" Value="{Binding Mode=TwoWay, Path=IsSelected}"/>
</Style>
</ListBox.ItemContainerStyle>
</ListBox>
</Border>
<Grid Grid.Row="3" Grid.Column="3">
<Grid.RowDefinitions>
<RowDefinition Height="10*" />
<RowDefinition Height="15*" />
<RowDefinition Height="15*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Label Content="Granularity:" Grid.Column="0" Grid.Row="0" Height="25" Name="label5" Grid.ColumnSpan="3" />
<Button Content="Select All" Command="{Binding SelectAll}" Grid.ColumnSpan="2"
Grid.Column="0" Grid.Row="1" Height="23" HorizontalAlignment="Stretch" Name="btnSelectAll" Width="75" IsEnabled="{Binding Path=AllPropertiesValid}" />
<Button Content="Unselect All" Grid.Column="0" Grid.Row="2" Height="23" HorizontalAlignment="Stretch" Command="{Binding UnSelectAll}"
Name="btnUnselectAll" Width="75" IsEnabled="{Binding Path=AllPropertiesValid}" Grid.ColumnSpan="2" />
</Grid>
</Grid>
</UserControl>
and my Mainwindow code is
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:View="clr-namespace:Class.View" x:Class="ELT_Data_Extractor.ELT_Data_Extract"
Height="620" Width="586" WindowStartupLocation="CenterScreen">
<View:DataBaseBrowser HorizontalAlignment="Center" Width="576" VerticalAlignment="Top" Height="550" Margin="1,0" />
<Button x:Name="CancelButton" Content="Cancel" Width="75" Height="23" HorizontalAlignment="Right" Margin="0,528,15,29" Click="CancelButton_Click" />
<Button x:Name="OKButton" Content="OK" Width="75" Height="23" HorizontalAlignment="Right" Margin="0,528,101,29" Click="OKButton_Click" />
</Grid>
</Window>
When i maximize the window the usercontrol also fit it as well as window
could you please provide any solution to me.
What I have tried:
i Goodled this issue and i didn't solve my issue.and i tried remove height and width for user control but it's not working and i tried this below link solution also it's not working
[
^]