56 lines
1.7 KiB
C#
56 lines
1.7 KiB
C#
|
|
using System.Windows;
|
|||
|
|
using System.Windows.Controls;
|
|||
|
|
|
|||
|
|
using BeWo.ViewModel;
|
|||
|
|
|
|||
|
|
namespace BeWo.View
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// Interaction logic for VarFieldEditControl.xaml
|
|||
|
|
/// </summary>
|
|||
|
|
public partial class VarFieldEditControl : UserControl
|
|||
|
|
{
|
|||
|
|
public static readonly DependencyProperty VarFieldVMProperty = DependencyProperty.Register(
|
|||
|
|
"VarFieldVM",
|
|||
|
|
typeof(VarFieldVM),
|
|||
|
|
typeof(VarFieldEditControl),
|
|||
|
|
new UIPropertyMetadata(
|
|||
|
|
(s, e) =>
|
|||
|
|
{
|
|||
|
|
var vm = e.NewValue as VarFieldVM;
|
|||
|
|
var c = s as VarFieldEditControl;
|
|||
|
|
c.DataContext = vm;
|
|||
|
|
var control = c.FindResource(vm.ControlType) as Control;
|
|||
|
|
if (vm.Width.HasValue)
|
|||
|
|
{
|
|||
|
|
control.HorizontalAlignment = HorizontalAlignment.Left;
|
|||
|
|
control.Width = vm.Width.Value;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
control.HorizontalAlignment = HorizontalAlignment.Stretch;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
c.grid_root.Children.Add(control);
|
|||
|
|
}));
|
|||
|
|
|
|||
|
|
public VarFieldEditControl()
|
|||
|
|
{
|
|||
|
|
this.InitializeComponent();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public VarFieldVM VarFieldVM
|
|||
|
|
{
|
|||
|
|
get
|
|||
|
|
{
|
|||
|
|
return (VarFieldVM)this.GetValue(VarFieldVMProperty);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
set
|
|||
|
|
{
|
|||
|
|
this.SetValue(VarFieldVMProperty, value);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|