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

Top-level Self-binding DataContext in Page is not working #212

Closed
Daoting opened this issue Sep 21, 2018 · 8 comments
Closed

Top-level Self-binding DataContext in Page is not working #212

Daoting opened this issue Sep 21, 2018 · 8 comments
Assignees
Labels
difficulty/starter 🚀 Categorizes an issue for which the difficulty level is reachable by newcomers kind/bug Something isn't working low-hanging-🍒 Categorizes an issue that might be a quick win with meaningful positive impact. project/binding 🪢 Categorizes an issue or PR as relevant to the binding engine triage/potentially-fixed Categorizes an issue as potentially fixed by some unlinked PR, fix needs to be verified

Comments

@Daoting
Copy link
Contributor

Daoting commented Sep 21, 2018

I'm submitting a...

  • Bug report (I searched for similar issues and did not find one)

Current behavior

TextBox does not support text binding in iOS. UI is no response when include text binding.
<TextBox Text="{Binding Title}" />

Expected behavior

Minimal reproduction of the problem with instructions

Environment

Nuget Package: 

Package Version(s): 

Affected platform(s):
- [x] iOS
- [ ] Android
- [ ] WebAssembly
- [ ] Windows
- [ ] Build tasks

Visual Studio
- [x] 2017 (version: )
- [ ] 2017 Preview (version: )
- [ ] for Mac (version: )

Relevant plugins
- [ ] Resharper (version: )
@MatFillion
Copy link
Contributor

MatFillion commented Sep 21, 2018

Thank you @Daoting for your report.

Typically I bind the Text property of TextBox using

<TextBox Text="{Binding FirstName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />

Could you provide your code sample? (XAML and C# DataContext) It would help use understand and reproduce your issue.

@Daoting
Copy link
Contributor Author

Daoting commented Sep 25, 2018

xaml:

<dt:PageWin
    x:Class="Dt.Sample.TestDemo1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    xmlns:dt="using:Dt.Base">

    <TextBox Text="{Binding Title}" />
</dt:PageWin>

Code:

    public sealed partial class TestDemo1 : PageWin
    {
        public TestDemo1()
        {
            InitializeComponent();
            DataContext = this;
        }
    }

Title's define:

    public partial class PageWin : ContentControl, IWin
    {
        public readonly static DependencyProperty TitleProperty = DependencyProperty.Register(
            "Title",
            typeof(string),
            typeof(PageWin),
           new PropertyMetadata("No Title"));
           
           
        public string Title
        {
            get { return (string)GetValue(TitleProperty); }
            set { SetValue(TitleProperty, value); }
        }
    }

It cannot load the ui that include text binding. Thanks @MatFillion .

@jeromelaban
Copy link
Member

There may be an issue with self-DataContext binding. Can you try with a sub-object, or using x:Bind ?

@jeromelaban jeromelaban added the kind/bug Something isn't working label Sep 26, 2018
@Daoting
Copy link
Contributor Author

Daoting commented Sep 27, 2018

Yes, sub-object, ElementName, x:Bind are ok. Only self-DataContext binding.

@jeromelaban jeromelaban changed the title TextBox does not support text binding in iOS Top-level Self-binding DataContext in Page is not working Oct 2, 2018
@ghuntley ghuntley added the platform/ios 🍎 Categorizes an issue or PR as relevant to the iOS platform label May 22, 2019
@jeromelaban jeromelaban added the project/binding 🪢 Categorizes an issue or PR as relevant to the binding engine label Sep 15, 2020
@agneszitte agneszitte added project/animations 🎡 Categorizes an issue or PR as relevant to animations and removed project/animations 🎡 Categorizes an issue or PR as relevant to animations priority/important-longterm labels Sep 21, 2020
@jeromelaban jeromelaban added the difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. label Feb 15, 2021
@MartinZikmund MartinZikmund added difficulty/starter 🚀 Categorizes an issue for which the difficulty level is reachable by newcomers and removed difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. labels May 31, 2021
@MartinZikmund MartinZikmund added low-hanging-🍒 Categorizes an issue that might be a quick win with meaningful positive impact. and removed platform/ios 🍎 Categorizes an issue or PR as relevant to the iOS platform labels May 22, 2024
@MartinZikmund MartinZikmund added the triage/potentially-fixed Categorizes an issue as potentially fixed by some unlinked PR, fix needs to be verified label Sep 16, 2024
@morning4coffe-dev
Copy link
Member

I have tested this one with Android, everything there seems to work as expected now. I will test with the team on iOS as well.

@rajamatt
Copy link
Contributor

@morning4coffe-dev On iOS control appears and binding is working.

image

@morning4coffe-dev
Copy link
Member

Thanks @rajamatt! This is the same behavior I am seeing on WinUI and Android as well. Can we close @MartinZikmund?

@MartinZikmund
Copy link
Member

Yes, closing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty/starter 🚀 Categorizes an issue for which the difficulty level is reachable by newcomers kind/bug Something isn't working low-hanging-🍒 Categorizes an issue that might be a quick win with meaningful positive impact. project/binding 🪢 Categorizes an issue or PR as relevant to the binding engine triage/potentially-fixed Categorizes an issue as potentially fixed by some unlinked PR, fix needs to be verified
Projects
None yet
Development

No branches or pull requests

8 participants