danturn 1 Light Poster

Hey guys,

i'm struggling slightly with my UI for a project.

I have a listview bound to a observablecollection (userList) of users, users has 3 properties (windowsUser,PhoneUserId,PhonePin)

i have an edit button, and update button and three text boxes (TBWindowsUser, TBPhoneUserID, TBPhonePin)

when i click the edit button i want the selected item in the listview to populate the corresponding text boxes then the user can edit the values and click update to apply the changes...

I've almost got this working... but it also updates when you tab between the text boxes i need it to not update until you click the button at the end...

any ideas?

(in case you're wondering im setting the binding programatically at the point when the edit button is clicked because the text boxes can also be used to add a new user which doesnt exist in the list box at all - i've removed that part of the code - If you have any other way of performing this arrangement let me know!)
code here:


<StackPanel Name ="MainStack" DataContext="{Binding Source = userList}" Height="348">
        <Grid Height="348">
        <TextBox Height="23" HorizontalAlignment="Left" Margin="24,32,0,0" Name="TBWindowsUser" VerticalAlignment="Top" Width="120" />
        <TextBox Height="23" HorizontalAlignment="Left" Margin="24,66,0,0" Name="TBPhoneUserId" VerticalAlignment="Top" Width="56" />
        <PasswordBox Margin="91,66,0,0" x:Name="TBPhonePin" PasswordChar="*" HorizontalAlignment="Left" Width="53" Height="23" VerticalAlignment="Top" />
        <Button Height="23" HorizontalAlignment="Right" Click="BUpdateUser_Click" Margin="0,66,61,0" Name="BUpdate" VerticalAlignment="Top" Width="75">Update User</Button>
        <ListView Margin="24,102,24,39" Name="LVUsers" IsSynchronizedWithCurrentItem="True" ItemsSource="{Binding}">
                    <GridViewColumn Header="Windows User" Width="100" DisplayMemberBinding="{Binding Path=WindowsUser}" />
                    <GridViewColumn Header="Phone User ID" Width="100" DisplayMemberBinding="{Binding Path=PhoneUserId}" />
        <Button Height="23" HorizontalAlignment="Right" Click="BSave_Click" Name="BSave" VerticalAlignment="Bottom" Width="52" Margin="0,0,24,8">Save</Button>
        <Button Height="23" HorizontalAlignment="Left" Click ="BEdit_Click" Margin="24,0,0,8" Name="BEdit" VerticalAlignment="Bottom" Width="48">Edit</Button>


private void BEdit_Click(object sender, RoutedEventArgs e)
            BAddUser.Content = "Update";

            BindingOperations.SetBinding(TBWindowsUser, text, new Binding("/WindowsUser"));
            BindingOperations.SetBinding(TBPhoneUserId, text, new Binding("/PhoneUserId"));
            BindingOperations.SetBinding(TBPhonePin, password, new Binding("/PhonePin"));
            LVUsers.IsEnabled = false;
private void BUpdate_Click(object sender, RoutedEventArgs e)
   LVUsers.IsEnabled = true;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.