WPF: Set not being hit on 2way binding



I have an IEnumerable on twoway binding. When selected it populates the element info into a text box. However none of these edits triggers the set operation for my binded object.


C#



private IEnumerable<XElement> _Steps
{
get
{
if (_Xdoc== null) return null;
else
return (_Xdoc.Descendants().Where(x => x.Name == ns + "Implementation").Elements());
}
}
set
{
XElement xNode = _Steps.Elements().Except(value).First();
XElement replaceNode = value.Elements().Except(_Steps).First();
_Xdoc.ToString().Replace(xNode.ToString(), value.ToString());
}
}

public IEnumerable<XElement> Steps {
get { return _Steps; }
set { _Steps = value; } }


XAML



<ListView HorizontalAlignment="Stretch" Name="listView1" VerticalAlignment="Top" Grid.Column="0" Grid.Row="1"
ItemsSource="{Binding Steps, Mode=TwoWay }" Grid.RowSpan="3">
<ListView.View>
<GridView>

<GridViewColumn Header="Name" DisplayMemberBinding="{Binding Path=Attribute[name].Value}" />
</GridView>
</ListView.View>
</ListView>
<GridSplitter HorizontalAlignment="Left" Height="100" VerticalAlignment="Top" Width="6" Grid.Column="1" Margin="2.6,80,0,0" Grid.Row="2"/>
<WrapPanel Grid.Row="1" Grid.Column="1">
<Label Content="StepID:" Grid.Column="1" HorizontalAlignment="Left" Grid.Row="1" VerticalAlignment="Top" />
<Label Content="{Binding Path=Attribute[stepID].Value}" HorizontalAlignment="Left" VerticalAlignment="Top" DataContext="{Binding SelectedItem, ElementName=listView1, Mode=TwoWay }" />
</WrapPanel>
<TextBox Grid.Column="1" Grid.Row="2" Grid.ColumnSpan="2" Grid.RowSpan="3" Margin="10,0,0,0"
Text="{Binding SelectedItem, ElementName=listView1, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged }" TextWrapping="Wrap" AcceptsReturn="True" >

</TextBox>


Any ideas.


No comments:

Post a Comment