Hi,
I am new to WPF and Telerik controls. I have been through the online documentation, the RadControls Demos that install with the controls, various forums and reference material including the telerik forums. I have tried several pieces of code and I can't get the TwoWay binding to work. I can achieve what I want to do with CodeBehind but that is sort of defeating the purpose.
So I have a RadGridView that is populated by a dataset. I do this by the code below. rgvSamples is the RadGridView. dsMain is a dataset.
In XAML I then set the various DataContext and Bindings as seen below.
The above code above does not actually work even though it is almost identical to some of the solutions posted on this forum. I also have a standalone Textbox as seen in the code below which also does not work.
Now by making the following changes I get the first value in the GridView to show but that is it. If I select a different row then the value in the textbox does not change.
So I have been going through forum posts etc for about 3 days now trying to see what i am doing wrong. can some one please point me in the correct direction.
Thanx
Kind Regards
Richard
I am new to WPF and Telerik controls. I have been through the online documentation, the RadControls Demos that install with the controls, various forums and reference material including the telerik forums. I have tried several pieces of code and I can't get the TwoWay binding to work. I can achieve what I want to do with CodeBehind but that is sort of defeating the purpose.
So I have a RadGridView that is populated by a dataset. I do this by the code below. rgvSamples is the RadGridView. dsMain is a dataset.
rgvSamples.ItemsSource = dsMain.Tables["Samples"];
In XAML I then set the various DataContext and Bindings as seen below.
<
StackPanel
Height
=
"357"
HorizontalAlignment
=
"Left"
Margin
=
"736,25,0,0"
Name
=
"stackPanel1"
VerticalAlignment
=
"Top"
Width
=
"211"
>
<
Grid
Height
=
"51"
Name
=
"grid1"
Width
=
"212"
DataContext
=
"{Binding ElementName=rgvSamples, Path=SelectedItem}"
>
<
TextBox
Height
=
"23"
HorizontalAlignment
=
"Left"
Margin
=
"55,6,0,0"
x:Name
=
"textBox1"
VerticalAlignment
=
"Top"
Width
=
"143"
Text
=
"{Binding Path=CodeStr, Mode=TwoWay}"
/>
<
Label
Content
=
"Label"
Height
=
"23"
HorizontalAlignment
=
"Left"
Margin
=
"6,6,0,0"
Name
=
"label1"
VerticalAlignment
=
"Top"
Width
=
"43"
/>
</
Grid
>
</
StackPanel
>
The above code above does not actually work even though it is almost identical to some of the solutions posted on this forum. I also have a standalone Textbox as seen in the code below which also does not work.
<
TextBox
Height
=
"36"
HorizontalAlignment
=
"Left"
Margin
=
"580,145,0,0"
Name
=
"textBox2"
VerticalAlignment
=
"Top"
Width
=
"120"
Text
=
"{Binding ElementName=rgvSamples, Path=SelectedItem.CodeStr}"
/>
Now by making the following changes I get the first value in the GridView to show but that is it. If I select a different row then the value in the textbox does not change.
rgvSamples.ItemsSource = dsMain.Tables["Samples"];
stackPanel1.DataContext = rgvSamples.ItemsSource;
<
StackPanel
Height
=
"357"
HorizontalAlignment
=
"Left"
Margin
=
"736,25,0,0"
Name
=
"stackPanel1"
VerticalAlignment
=
"Top"
Width
=
"211"
>
<
Grid
Height
=
"51"
Name
=
"grid1"
Width
=
"212"
DataContext
=
"{Binding CurrentItem}"
>
<
TextBox
Height
=
"23"
HorizontalAlignment
=
"Left"
Margin
=
"55,6,0,0"
x:Name
=
"textBox1"
VerticalAlignment
=
"Top"
Width
=
"143"
Text
=
"{Binding CodeStr, Mode=TwoWay}"
/>
<
Label
Content
=
"Label"
Height
=
"23"
HorizontalAlignment
=
"Left"
Margin
=
"6,6,0,0"
Name
=
"label1"
VerticalAlignment
=
"Top"
Width
=
"43"
/>
</
Grid
>
</
StackPanel
>
So I have been going through forum posts etc for about 3 days now trying to see what i am doing wrong. can some one please point me in the correct direction.
Thanx
Kind Regards
Richard