0
중첩 컨트롤의 두 가지 종속성 속성을 노출하려고합니다. 이 경우 Mask
및 DisplayFormatString
입니다. 내가 노력하고 내가 잘못 입력 형식에 관한 예외가 부모 컨트롤에 속성을 설정할 때중첩 된 종속성 속성을 사용하여 UserControl을 초기화 할 수 없습니다.
<UserControl
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:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
xmlns:local="clr-namespace:View.UserControls"
xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core" x:Class="View.UserControls.DateTimeEdit"
mc:Ignorable="d" >
<Grid>
<dxe:DateEdit x:Name="localDateEdit" Width="200" MaskType="DateTime"
ShowEditorButtons="True"
Mask ="dd MMM yyyy HH:mm"
DisplayFormatString = "dd MMM yyyy HH:mm"/>
</Grid>
</UserControl>
나는, 부모 컨트롤 그러나
public partial class DateTimeEdit : UserControl
{
public static readonly DependencyProperty DisplayFormatStringProperty =
DependencyProperty.Register("DisplayFormatString", typeof(string), typeof(DateTimeEdit), new PropertyMetadata(0));
public static readonly DependencyProperty MaskProperty =
DependencyProperty.Register("Mask", typeof(string), typeof(DateTimeEdit), new PropertyMetadata(0));
public string DisplayFormatString
{
get { return (string)GetValue(DisplayFormatStringProperty); }
set { SetValue(DisplayFormatStringProperty, value); }
}
public string Mask
{
get { return (string)GetValue(MaskProperty); }
set { SetValue(MaskProperty, value); }
}
public static void OnDisplayFormatStringChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
(d as DateTimeEdit).localDateEdit.DisplayFormatString = (string)e.NewValue;
}
public static void OnMaskChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
(d as DateTimeEdit).localDateEdit.Mask = (string)e.NewValue;
}
}
에 종속성 속성을 추가했습니다. Default value type does not match type of property 'DisplayFormatString'
UserControl 용도.
<userControls:DateTimeEdit
Mask="dd MMM yyyy"
DisplayFormatString="dd MMM yyyy"/>
중첩 된 종속성 속성이 올바르게 표시됩니까?