1
如何添加依賴項屬性到文本框並將依賴項屬性綁定到銀色光照下的布爾屬性。我的布爾屬性是在我的視圖模型中。將依賴項屬性添加到文本框
ImageSearchIsFocused是允許我在文本框中設置焦點的屬性。
<TextBox Text="{Binding ImgSearch, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
<i:Interaction.Behaviors>
<common:FocusBehavior HasInitialFocus="True" IsFocused="{Binding ImageSearchIsFocused, Mode=TwoWay}" ></common:FocusBehavior>
</i:Interaction.Behaviors>
</TextBox>
ImageIsFocused物業
bool _ImageSearchIsFocused;
public bool ImageSearchIsFocused
{
get { return _ImageSearchIsFocused; }
set
{
_ImageSearchIsFocused = value;
NotifyPropertyChanged("ImageSearchIsFocused");
}
}
什麼是你想添加的依賴屬性?您的示例僅顯示附加的行爲。你可以顯示你的代碼(例如行爲?) – 2012-07-13 08:11:42
@HiTech魔術這是我遵循http://jklogic.blogspot.com/2012/02/silverlight-setting-focus-to-text-box.html – SupaOden 2012-07-13 09:08:17
幫助。 ImageSearchIsFocused屬性的代碼是什麼樣的? – 2012-07-13 09:12:14