Я не уверен в вашей конкретной реализации, но я просто напишу пример, который может быть полезным.
XAML
<Window x:Name="MainWindow"
x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow"
MinWidth="200"
MinHeight="100"
Width="{Binding ElementName=MainWindow, Path=WindowWidth}"
Height="{Binding ElementName=MainWindow, Path=WindowHeight}">
<Grid>
<Slider
x:Name="slWidth"
Value="{Binding ElementName=MainWindow, Path=WindowWidth, Mode=TwoWay}"
Minimum="200"
Maximum="1600"
Height="23" HorizontalAlignment="Left" Margin="56,22,0,0" VerticalAlignment="Top" Width="61" />
<Label
Content="Width"
Height="28"
HorizontalAlignment="Left"
Margin="12,22,0,0"
Name="Label1"
VerticalAlignment="Top" />
<Slider
x:Name="slHeight"
Value="{Binding ElementName=MainWindow, Path=WindowHeight, Mode=TwoWay}"
Minimum="100"
Maximum="800"
Height="23" HorizontalAlignment="Left" VerticalAlignment="Top" Width="61" Margin="56,51,0,0" />
<Label
Content="Height"
Height="28"
HorizontalAlignment="Left"
VerticalAlignment="Top" Margin="12,46,0,0" />
</Grid>
</Window>
код
Class MainWindow
Public Shared ReadOnly WindowWidthProperty As DependencyProperty = _
DependencyProperty.Register("WindowWidth", _
GetType(Integer), GetType(MainWindow), _
New FrameworkPropertyMetadata(Nothing))
Public Shared ReadOnly WindowHeightProperty As DependencyProperty = _
DependencyProperty.Register("WindowHeight", _
GetType(Integer), GetType(MainWindow), _
New FrameworkPropertyMetadata(Nothing))
Public Property WindowWidth As Integer
Get
Return CInt(GetValue(WindowWidthProperty))
End Get
Set(ByVal value As Integer)
SetValue(WindowWidthProperty, value)
End Set
End Property
Public Property WindowHeight As Integer
Get
Return CInt(GetValue(WindowHeightProperty))
End Get
Set(ByVal value As Integer)
SetValue(WindowHeightProperty, value)
End Set
End Property
End Class
C # код
public readonly DependencyProperty WindowWidthProperty = DependencyProperty.Register("WindowWidth", typeof(Double), typeof(MainWindow), new FrameworkPropertyMetadata());
public readonly DependencyProperty WindowHeightProperty = DependencyProperty.Register("WindowHeight", typeof(Double), typeof(MainWindow), new FrameworkPropertyMetadata());
public double WindowWidth {
get { return Convert.ToDouble(this.GetValue(WindowWidthProperty)); }
set { this.SetValue(WindowWidthProperty, value); }
}
public double WindowHeight {
get { return Convert.ToDouble(this.GetValue(WindowHeightProperty)); }
set { this.SetValue(WindowHeightProperty, value); }
}