Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2 IpField controls bound to same IpAddress string results in lost focus #1

Open
zanderman112 opened this issue Aug 19, 2022 · 4 comments

Comments

@zanderman112
Copy link

zanderman112 commented Aug 19, 2022

Hi!

I am making an app that allows users to change settings for another piece of software.

We provide a section at the top of "most commonly changed settings" that we know will get modified often, however we then have different sections on the page for specific areas. An IP Address is one that will get changed often so we have 2 IpFields added in our xaml, one in the common section, and one in the "Communication" section.

Both of these IpField controls are bound to the same property in the viewmodel called IpAddress.

The bug is that when I am typing into one of the IpFields, as soon as I enter a character, the IpField I was typing in loses focus, and then both IpFields have the single character that I typed in them, but I cannot type further without clicking into the control again.

My relevant xaml looks something like this and any advice you might have for this is super helpful:

<UserControl d:DataContext="{d:DesignInstance Type=MyViewModel}">
   <Expander Name="CommonSettings">
       <IpField IpAddress={Binding IpAddress}/>
   </Expander
   
   <!-- This expander is a section specifically for communication related controls -->
   <Expander Name="CommunicationSettings">
         <!-- Notice I am binding to the same property as above on my view model-->
         <IpField IpAddress={Binding IpAddress}/>
         
         <!-- more controls related to communication -->
   </Expander
   
   <Expander Name="SomeMoreSettings">
       <!-- more controls -->
   </Expander
   <!-- 
           Note that there are MANY expanders here, and the common section above is meant to put a lot of the common settings 
           but that each individual section also has the settings as well
    -->
</UserControl>
@omidmohajers
Copy link

Hi!
I change your code to :
<ip:IpField IpAddress="{Binding IpAddress , Mode=TwoWay}" />
and work
I fork this repository and update code and sample
check this on :
https://github.com/omidmohajers/IPUserControls

@zanderman112
Copy link
Author

Hi @omidmohajers, I will try to see if I can use your solution soon. From what I can tell on your example, only one of the IpFields is actually binding to the IpAddress property, but I am viewing it in my phone so maybe I missed something.

@omidmohajers
Copy link

HI @zanderman112, I Will Create multiple binding sample very soon like this :
image

@omidmohajers
Copy link

Hi @zanderman112
check this for data binding sample :
https://github.com/omidmohajers/ip-changer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants