One of the major motivations to port Windows Forms applications to WPF are powerful data binding capabilities. Using TX Text Control .NET for WPF, interface controls like buttons or dropdown menus of a Ribbon bar can be easily connected to TX Text Control without writing one line of C# or VB.NET code. The connection can be completely done in XAML, making such bindings quick, flexible and easy.
To implement WPF data binding, a target and a source is required. The target can be any public property or element which is derived from DependencyProperty. The source of a WPF binding can be any property or other objects.
An example:
A ToggleButton should visualize, whether the character formatting at the current input position is bold or not and it should change this state when the button is clicked. In this case, the target of the data binding is the IsChecked property of the ToggleButton. The source is the Bold property of the new TX Text Control WPF.InputFormat class. This class represents all formatting attributes at the current text input position. The properties of this class are updated automatically when the input position changes.
The following XAML code shows the ToggleButton and it's binding:
In the Binding statement the Mode attribute has been set to TwoWay. This attribute specifies how the data flows between the source and the target. The following methods are available:
* OneWay:
The data flows from the source to target each time a change is made on the source.
* TwoWay:
The data flows from the source to target and vice versa each time a change is made on the source or target.
* OneTime:
The data flows from the source to target when the application is started.
* OneWayToSource:
The data flows from the target to source each time a change is made on the target.
In this sample, a textual ToggleButton is used and text can be changed when the button is checked. Also for this action we don't need any code behind and it can be done directly in XAML. A Trigger can be used to listen to the IsChecked property in order to change the text accordingly. If you bind the Value of the Content property, it must not be set as a parameter in the ToggleButton element directly:
This is a just a foretaste of the new features of TX Text Control .NET for WPF. In the coming weeks, I will introduce more of these great improvements.
About TX Text Control:
TX Text Control was originally released in 1991, since then more than 40,000 copies have been sold. Starting off as a single, small DLL, TX Text Control has made its way through 16-bit DLL and VBX versions to today's Enterprise edition with its .NET and ActiveX components. The recent addition to the family, TX Text Control .NET Server, offers all of TX Text Control advanced word processing functionality in an easy-to-use server-side .NET component. Customers benefit from these years of experience, large user base, and at the same time, appreciate developing with a mature, reliable product.
Contact Informations:
support@textcontrol.com
North & South America:
Phone: +1 704-370-0110
Phone: +1 877-462-4772 (toll free)
Europe:
Phone: +49 421 335 910
Asia Pacific:
Phone: +886 2-2797-8508
To implement WPF data binding, a target and a source is required. The target can be any public property or element which is derived from DependencyProperty. The source of a WPF binding can be any property or other objects.
An example:
A ToggleButton should visualize, whether the character formatting at the current input position is bold or not and it should change this state when the button is clicked. In this case, the target of the data binding is the IsChecked property of the ToggleButton. The source is the Bold property of the new TX Text Control WPF.InputFormat class. This class represents all formatting attributes at the current text input position. The properties of this class are updated automatically when the input position changes.
The following XAML code shows the ToggleButton and it's binding:
HTML:
<ToggleButton Name="tbtnBold" Content="Bold" Focusable="False"
IsChecked="{Binding
ElementName=textControl1,
Path=InputFormat.Bold, Mode=TwoWay}" />
In the Binding statement the Mode attribute has been set to TwoWay. This attribute specifies how the data flows between the source and the target. The following methods are available:
* OneWay:
The data flows from the source to target each time a change is made on the source.
* TwoWay:
The data flows from the source to target and vice versa each time a change is made on the source or target.
* OneTime:
The data flows from the source to target when the application is started.
* OneWayToSource:
The data flows from the target to source each time a change is made on the target.
In this sample, a textual ToggleButton is used and text can be changed when the button is checked. Also for this action we don't need any code behind and it can be done directly in XAML. A Trigger can be used to listen to the IsChecked property in order to change the text accordingly. If you bind the Value of the Content property, it must not be set as a parameter in the ToggleButton element directly:
HTML:
<ToggleButton Name="tbtnBold" Focusable="False"
IsChecked="{Binding
ElementName=textControl1,
Path=InputFormat.Bold, Mode=TwoWay}">
<ToggleButton.Style>
<Style TargetType="{x:Type ToggleButton}">
<Setter Property="Content" Value="Bold"/>
<Style.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter Property="Content" Value="UnBold"/>
</Trigger>
</Style.Triggers>
</Style>
</ToggleButton.Style>
</ToggleButton>
This is a just a foretaste of the new features of TX Text Control .NET for WPF. In the coming weeks, I will introduce more of these great improvements.
About TX Text Control:
TX Text Control was originally released in 1991, since then more than 40,000 copies have been sold. Starting off as a single, small DLL, TX Text Control has made its way through 16-bit DLL and VBX versions to today's Enterprise edition with its .NET and ActiveX components. The recent addition to the family, TX Text Control .NET Server, offers all of TX Text Control advanced word processing functionality in an easy-to-use server-side .NET component. Customers benefit from these years of experience, large user base, and at the same time, appreciate developing with a mature, reliable product.
Contact Informations:
support@textcontrol.com
North & South America:
Phone: +1 704-370-0110
Phone: +1 877-462-4772 (toll free)
Europe:
Phone: +49 421 335 910
Asia Pacific:
Phone: +886 2-2797-8508