XAML refactoring, especially for Rename of properties for Databinding
Currently renaming a property that is databound does NOT rename the binding in the XAML, or the string in the notify property change.
Ex: Currently, When you change MyInt to be something else
Backing ViewModel.cs:
int _myInt;
public int MyInt // Changes
{
get { return _myInt; }
set
{
if (_myInt != value)
{
_myInt = value;
if(PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs("MyInt")); /this String does not change
}
}
}
}
SomeXaml.xaml:
<TextBlock Text={Binding MyInt}/> <!-- This MyInt also does not currently update -->
<!-- Other references in Xaml to MyInt also do not change -->
2 comments
-
Julien N
commented
I guess this is worse : the code I got had a property named "Width" in the ViewModel, which I renamed to a more appropriate name.
But it renamed ALL the unrelated Width properties of ALL the XAML files of the project to the new name (except in the databinding, in short it renamed everything that shouldn't be and didn't the only one that should...). -
Jim wallace
commented
None of my Xaml showed up, I expect because it looks like HTML tags.
TextBlock Text={Binding MyInt} // this does not change in XAML, nor does any other reference to MyInt