C # UWP Windows 10 project
Described controls based on TextBox , when initializing, Binding works, but does not respond to INotifyProperryChanged. In the template, the control writes the following:
The "Property" property is not a DependencyProperty property. To use unattached properties in markup, you must provide a target type with an available property of the "Symbol" instance. For attached properties, the "GetSymbol" and "SetSymbol" static methods must be represented in the declaring type. "
Control Code:
public sealed class CurrencyTextBox : TextBox { public CurrencyTextBox() { DefaultStyleKey = typeof(CurrencyTextBox); } public string Symbol { get { return (string)GetValue(CurrencySymbolProperty); } set { SetValue(CurrencySymbolProperty, value); } } public static readonly DependencyProperty CurrencySymbolProperty = DependencyProperty.Register("Symbol", typeof(string), typeof(CurrencyTextBox), new PropertyMetadata("", new PropertyChangedCallback(OnSymbolChanged))); private static void OnSymbolChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { ((CurrencyTextBox)d).Symbol = (string)e.NewValue; } } A string from the template (immediately writes the error described above):
<TextBlock Grid.Row="2" Grid.Column="1" FontSize="{TemplateBinding FontSize}" FontWeight="SemiBold" Text="{TemplateBinding Symbol}" Margin="3,0,0,0"/>
TextBoxtemplate with another field - SYL<ControlTemplate TargetType="Button">, change it. Should take off. - VladD<ControlTemplate TargetType="Controls:CurrencyTextBox">and thebuttoninside<Grid.Resources> <Style x:Name="DeleteButtonStyle" TargetType="Button">, in theory should not affect - SYL