我是WPF中的新手。我需要使TwoWay和OneWayToSource绑定到字符串变量。我想使用Extended WPF Toolkit中的richtextbox,因为我认为这是简单的方法。扩展WPF工具包 - richtextbox的绑定文本
所以我尝试使用richtebox从这个库中的XAML,代码是在这里:
<Window x:Class="PokecMessanger.ChatWindow"
xmlns:extToolkit="clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit.Extended"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="ChatWindow" Height="429" Width="924">
///...
<extToolkit:RichTextBox Name="rtbRpText" Text="{Binding _rpText, Mode=OneWayToSource}" Grid.Column="0"></extToolkit:RichTextBox>
在后面的代码,我有这样的代码:
private string _rpText = string.Empty;
public ChatWindow(PokecCommands pokecCmd)
{
rtbRpText.DataContext = _rpText;
}
问题是,如果我写的东西richtextbox,变量_rpText仍然是空的,哪里可以解决问题?
它不工作,我的RichTextBox的属性文本绑定到变量字符串,没有串财产,你的解决方案的工作只有当我绑定到字符串属性实现INotifyPropertyChanged的类。 – Joe 2010-11-07 17:10:35
如果没有财产变更通知,您会如何预计它会起作用? – 2010-11-07 18:02:20
Sory,我不知道。所以这个接口是一个条件。 – Joe 2010-11-07 18:10:11