- noesis_user
- Posts: 14
- Joined:
TextBlock Text change event
Hi,
I have a text block and I need to capture its text change event to do certain things.
XAML:
Code:
TextBoxDataModel class:
But still I don't get notified when text changes in textBlock. What am I missing?
Thanks.
I have a text block and I need to capture its text change event to do certain things.
XAML:
Code: Select all
<TextBlock x:Name="TextBoxToothNumber" HorizontalAlignment="Right" Height="23" TextWrapping="Wrap"
VerticalAlignment="Top" Width="54" FontSize="16" Margin="0,15,10,0" Background="{x:Null}"
Foreground="White" FontWeight="Normal" Text="{Binding SimpleText}"/>
Code: Select all
TextBoxDataModel* t_ = new TextBoxDataModel();
Binding* b = new Binding("SimpleText");
b->SetSource(t_);
BindingOperations::SetBinding( tooth_number_block, TextBlock::TextProperty, b);
Code: Select all
class TextBoxDataModel: public Noesis::Core::BaseComponent,
public Noesis::Gui::INotifyPropertyChange
{
public:
TextBoxDataModel() : _simpleText("yay")
{ }
~TextBoxDataModel()
{}
const NsChar* GetSimpleText() const
{
return _simpleText;
}
void SetSimpleText(const NsChar* simpleText)
{
if (_simpleText != simpleText)
{
_simpleText = simpleText;
_changedEvent(this, NSS(SimpleText));
}
}
/// From INotifyPropertyChange
//@{
PropertyChangedEvent& PropertyChanged()
{
return _changedEvent;
}
DestroyedDelegate& Destroyed()
{
return _destroyedEvent;
}
//@}
private:
const NsChar* _simpleText;
PropertyChangedEvent _changedEvent;
DestroyedDelegate _destroyedEvent;
NS_IMPLEMENT_INLINE_REFLECTION(TextBoxDataModel, BaseComponent)
{
NsMeta<Noesis::Core::TypeId>("TextBoxDataModel");
NsImpl<INotifyPropertyChange>();
NsProp("SimpleText", &TextBoxDataModel::GetSimpleText, &TextBoxDataModel::SetSimpleText);
}
};
Thanks.
-
sfernandez
Site Admin
- Posts: 3188
- Joined:
Re: TextBlock Text change event
The TextBlock class doesn't define a TextChanged event, maybe you want to use a TextBox control:
Have you tried this way?
Code: Select all
<TextBox x:Name="TextBoxToothNumber" HorizontalAlignment="Right" Height="23" TextWrapping="Wrap"
VerticalAlignment="Top" Width="54" FontSize="16" Margin="0,15,10,0" Background="{x:Null}"
Foreground="White" FontWeight="Normal" Text="{Binding SimpleText}"/>
Who is online
Users browsing this forum: Bing [Bot] and 3 guests