내 Windows phone 앱에 숫자 컨트롤이 필요합니다.컨트롤의 속성을 컨트롤의 요소의 속성에 바인딩하는 방법?
사용자 지정 컨트롤을 만들려고하지만 컨트롤의 속성을 컨트롤의 요소에 바인딩 할 수 없습니다.
나는 제어
public static readonly DependencyProperty LineThicknessProperty =
DependencyProperty.Register("LineThickness", typeof (double), typeof (DigitControl), new PropertyMetadata(default(double)));
[DefaultValue(10D)]
public double LineThickness
{
get { return (double) GetValue(LineThicknessProperty); }
set { SetValue(LineThicknessProperty, value); }
}
에 종속성 속성을 추가했다 그리고 컨트롤의 요소
<UserControl x:Class="Library.DigitControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
d:DesignHeight="480" d:DesignWidth="480">
<Grid x:Name="LayoutRoot">
<Rectangle Margin="0" StrokeThickness="0" Width="{Binding LineThickness, RelativeSource={RelativeSource Self}}" Fill="#FFFF5454" RadiusX="5" RadiusY="5"/>
</Grid>
</UserControl>
에 바인딩을 시도했지만 작동하지 않습니다. 해당 속성을 요소의 속성에 바인딩하는 방법은 어디에 있습니까?
이 방법으로 문제를 해결했습니다. –