Files
BeWoPlaner/BeWo/View/Controls/Wohnhilfe/CustomerWohnhilfeControl.xaml.cs
Rene Evertz d69164fda2 Responsive Design
- Button Click muss noch IsLarge in Control triggern
2024-09-06 15:22:48 +02:00

107 lines
3.2 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace BeWo.View.Controls.Wohnhilfe
{
/// <summary>
/// Interaktionslogik für CustomerWohnhilfeControl.xaml
/// </summary>
public partial class CustomerWohnhilfeControl : UserControl
{
public bool IsLarge
{
get { return (bool)GetValue(IsLargeProperty); }
set { SetValue(IsLargeProperty, value); }
}
// Using a DependencyProperty as the backing store for IsLarge. This enables animation, styling, binding, etc...
public static readonly DependencyProperty IsLargeProperty =
DependencyProperty.Register("IsLarge", typeof(bool), typeof(CustomerWohnhilfeControl), new PropertyMetadata(false));
public double MinWidthGrid { get; set; }
public double ParentWidth
{
get { return (double)GetValue(ParentWidthProperty); }
set { SetValue(ParentWidthProperty, value); }
}
// Using a DependencyProperty as the backing store for ParentWidth. This enables animation, styling, binding, etc...
public static readonly DependencyProperty ParentWidthProperty =
DependencyProperty.Register("ParentWidth", typeof(double), typeof(CustomerWohnhilfeControl), new PropertyMetadata(0.0d));
public CustomerWohnhilfeControl()
{
InitializeComponent();
root_usercontrol.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
var size = root_usercontrol.DesiredSize;
MinWidthGrid = size.Width;
}
private void UserControl_SizeChanged(object sender, SizeChangedEventArgs e)
{
if (e.WidthChanged)
{
var parent_width = ParentWidth;
if (parent_width > MinWidthGrid + 50)
{
SetLarge();
}
else
{
SetSmall();
}
}
}
private void SetLarge()
{
if (IsLarge)
return;
IsLarge = true;
grid_secondcolumn.Width = new GridLength(2, GridUnitType.Star);
Grid.SetColumn(groupbox_2, 1);
Grid.SetRow(groupbox_2, 0);
Grid.SetColumn(groupbox_3, 0);
Grid.SetRow(groupbox_3, 1);
Grid.SetColumn(groupbox_4, 1);
Grid.SetRow(groupbox_4, 1);
}
private void SetSmall()
{
if (!IsLarge)
return;
IsLarge = false;
grid_secondcolumn.Width = new GridLength(0);
Grid.SetColumn(groupbox_2, 0);
Grid.SetRow(groupbox_2, 1);
Grid.SetColumn(groupbox_3, 0);
Grid.SetRow(groupbox_3, 2);
Grid.SetColumn(groupbox_4, 0);
Grid.SetRow(groupbox_4, 3);
}
}
}