Probleme mit Binding bei einem UserControl

  • Xamarin.Android

    Probleme mit Binding bei einem UserControl

    Hallo Leute und danke für's reinschauen.

    Ich versuche gerade einen eigenen UserControl zu basteln... Hab vorher sowas noch nie gemacht...

    Bis jetzt hab ich das:

    XML-Quellcode

    1. <?xml version="1.0" encoding="UTF-8"?>
    2. <StackLayout xmlns="http://xamarin.com/schemas/2014/forms"
    3. xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    4. xmlns:d="http://xamarin.com/schemas/2014/forms/design"
    5. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    6. mc:Ignorable="d" Orientation="Vertical"
    7. x:Class="wmMobileApp.wmTest">
    8. <Label Text="{Binding TextProperty}" Padding="0"></Label>
    9. <Frame Padding="4" HorizontalOptions="FillAndExpand" CornerRadius="5" OutlineColor="{Binding wmGray, FallbackValue=Gray}" BackgroundColor="{Binding wmGray, FallbackValue=Gray}" >
    10. <Frame Padding="5,5,5,5" HorizontalOptions="FillAndExpand" CornerRadius="5" OutlineColor="Red" BackgroundColor="White" >
    11. <Entry Text="{Binding Text, Mode=TwoWay}"></Entry>
    12. </Frame>
    13. </Frame>
    14. </StackLayout>


    C#-Quellcode

    1. ​using Xamarin.Forms;
    2. namespace wmMobileApp
    3. {
    4. public partial class wmTest : StackLayout
    5. {
    6. public wmTest()
    7. {
    8. InitializeComponent();
    9. BindingContext = this;
    10. }
    11. public static readonly BindableProperty TextProperty = BindableProperty.Create(nameof(Text), typeof(string), typeof(wmTest), "test", BindingMode.TwoWay);
    12. public string Text
    13. {
    14. get
    15. {
    16. return (string)GetValue(TextProperty);
    17. }
    18. set
    19. {
    20. SetValue(TextProperty, value);
    21. }
    22. }
    23. }
    24. }


    Was genau ist dran falsch, meine Variable wird nicht gebunden...

    XML-Quellcode

    1. ​xmlns:wmTest="clr-namespace:wmMobileApp"
    2. .....
    3. <wmTest:wmTest x:Name="Eugen" Text="{Binding Text, Mode=TwoWay}"></wmTest:wmTest>


    C#-Quellcode

    1. public wmMain()
    2. {
    3. InitializeComponent();
    4. BindingContext = new DataContextClass();
    5. }
    6. ....
    7. ....
    8. public class DataContextClass : wmBaseClass
    9. {
    10. public DataContextClass()
    11. {
    12. }
    13. private string _Text;
    14. public string Text
    15. {
    16. get
    17. {
    18. return _Text;
    19. }
    20. set
    21. {
    22. if (_Text == value)
    23. return;
    24. _Text = value;
    25. OnPropertyChanged("Text");
    26. }
    27. }
    28. }


    Sieht da einer was?