0
我目前正試圖定義一個附加的屬性可由用戶控件內的對象消費。附加屬性 - 「無法找到類型..上的樣式屬性..」
的附加屬性被登記在的代碼隱藏所述控制:
public partial class MapEditor : UserControl
{
public static readonly DependencyProperty LatitudeProperty =
DependencyProperty.RegisterAttached("Latitude", typeof(double), typeof(MapEditor));
//...
}
我然後試圖綁定到這些性質在一個ItemsControl:
<UserControl xmlns:Controls="clr-namespace:TestProject.Controls"
...>
<Grid>
...
<ItemsControl ItemsSource={Binding Items}>
<ItemsControl.ItemContainerStyle>
<Style TargetType="ContentPresenter">
<Setter Property="Controls:MapEditor.Latitude"
Value="1" />
</Style>
</ItemsControl.ItemContainerStyle>
</ItemsControl>
</Grid>
</UserControl>
但是我呈現與以下錯誤:
Error 6 Cannot find the Style Property 'Latitude' on the type 'TestProject.Controls.PhaseEditor'
是否有任何解決這個?我試圖完全在單獨的類文件中定義附加的屬性,但同樣的問題仍然存在。
非常感謝你,你救了我的一天!這似乎是當試圖使用附加的屬性和設置通過樣式('名稱=「屬性名稱」值=「屬性值」'希望你知道我的意思)它沒有這些靜態setter和getters的工作,但是,它沒有直接使用時在正常的xaml中。 – Mafii