0
我爲城市應用程序製作了自定義控件,並且希望從樣式中設置其屬性。但是它並沒有被調用。從樣式XAML設置自定義控件屬性
Control屬性:
public int FramesCount
{
get { return _framesCount; }
set
{
_framesCount = value;
if (ImageFileMask != null) ReloadFrames();
}
}
public static readonly DependencyProperty FramesCountProperty =
DependencyProperty.Register(
"FramesCount", typeof(int),
typeof(MyControl), null
);
XAML風格:
<Style TargetType="controls:MyControl" x:Key="wmLoadingBoxWaiting">
<Setter Property="Width" Value="32"/>
<Setter Property="Height" Value="32"/>
<Setter Property="FramesCount" Value="1"/>
</Style>
和頁面XAML:
<controls:MyControl HorizontalAlignment="Left" Margin="645,185,0,0" VerticalAlignment="Top" Style="{StaticResource wmLoadingBoxWaiting}"/>
標準特性(寬度和高度)是否正確設置好的,BYT德,崔根源財產FramesCount纔不是。它的setter只有在我直接在頁面XAML中設置而不是設置樣式時纔會調用。 有人知道我在做什麼錯嗎?
我試圖做到這一點,但沒有任何反應...... – Serhii