TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Yevgeniy Sydorko
NA
3
6k
DependencyProperty data binding
Aug 5 2011 7:32 AM
Hello!
I try to bind my UI to custom DependencyProperty:
...
<window.resources>
<local:localization x:key="Localization" ></local:localization>
</window.resources>
<grid name="mainStack" datacontext="{StaticResource Localization}">
<Button Padding="10,3" Margin="5" Content="{Binding Path=BtnAdd}" Command="New"/>;
</grid>
Also I have class "Localization":
class Localization : DependencyObject, INotifyPropertyChanged
{
public static DependencyProperty BtnAddProperty;
static Localization()
{
BtnAddProperty = DependencyProperty.Register("BtnAdd", typeof(string), typeof(Localization));
}
public string BtnAdd
{
set
{
SetValue(BtnAddProperty, value);
}
get
{
return (string)GetValue(BtnAddProperty);
}
}
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string propertyName)
{
PropertyChangedEventHandler handler = this.PropertyChanged;
if (handler != null)
{
PropertyChangedEventArgs e = new PropertyChangedEventArgs(propertyName);
handler.Invoke(this, e);
}
}
public Localization()
{
BtnAdd = MainWindowRes.BtnAdd;
}
public void SwitchLanguage()
{
BtnAdd = MainWindowRes.BtnAdd;
OnPropertyChanged("BtnAdd");
}
}
First time my UI element gets my property value. But when I use my method SwitchLanguage(), property gets new data, and UI still have first value.
Can someone help me please?
P.S.
Sorry, for my English.
Yevgeniy
Reply
Answers (
0
)
How to get superscript text in Combobox
Slide Show in wpf