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:
Was genau ist dran falsch, meine Variable wird nicht gebunden...
Sieht da einer was?
Ich versuche gerade einen eigenen UserControl zu basteln... Hab vorher sowas noch nie gemacht...
Bis jetzt hab ich das:
XML-Quellcode
-
- <?xml version="1.0" encoding="UTF-8"?>
- <StackLayout xmlns="http://xamarin.com/schemas/2014/forms"
- xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
- xmlns:d="http://xamarin.com/schemas/2014/forms/design"
- xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- mc:Ignorable="d" Orientation="Vertical"
- x:Class="wmMobileApp.wmTest">
- <Label Text="{Binding TextProperty}" Padding="0"></Label>
- <Frame Padding="4" HorizontalOptions="FillAndExpand" CornerRadius="5" OutlineColor="{Binding wmGray, FallbackValue=Gray}" BackgroundColor="{Binding wmGray, FallbackValue=Gray}" >
- <Frame Padding="5,5,5,5" HorizontalOptions="FillAndExpand" CornerRadius="5" OutlineColor="Red" BackgroundColor="White" >
- <Entry Text="{Binding Text, Mode=TwoWay}"></Entry>
- </Frame>
- </Frame>
- </StackLayout>
C#-Quellcode
- using Xamarin.Forms;
- namespace wmMobileApp
- {
- public partial class wmTest : StackLayout
- {
- public wmTest()
- {
- InitializeComponent();
- BindingContext = this;
- }
- public static readonly BindableProperty TextProperty = BindableProperty.Create(nameof(Text), typeof(string), typeof(wmTest), "test", BindingMode.TwoWay);
- public string Text
- {
- get
- {
- return (string)GetValue(TextProperty);
- }
- set
- {
- SetValue(TextProperty, value);
- }
- }
- }
- }
Was genau ist dran falsch, meine Variable wird nicht gebunden...
C#-Quellcode
-
- public wmMain()
- {
- InitializeComponent();
- BindingContext = new DataContextClass();
- }
- ....
- ....
- public class DataContextClass : wmBaseClass
- {
- public DataContextClass()
- {
- }
- private string _Text;
- public string Text
- {
- get
- {
- return _Text;
- }
- set
- {
- if (_Text == value)
- return;
- _Text = value;
- OnPropertyChanged("Text");
- }
- }
- }
Sieht da einer was?