Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Empfohlene Antworten

Veröffentlicht

Hallo

ich hoffe hier kann mir jemand helfen ich habe folgende XAML- Datei


<UserControl x:Class="LabelTextbox"

             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 

             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 

             xmlns:local="clr-namespace:HJSTFaktura.Steuerelemente"

             xmlns:System="clr-namespace:System;assembly=mscorlib"

             mc:Ignorable="d" 

             DataContext="{Binding RelativeSource={RelativeSource Self}}"

             x:Name="LabelTextbox"

             Height="22" Width="Auto"

             d:DesignHeight="22" d:DesignWidth="435">

    <WrapPanel>

        <Label Width="{Binding Path=HJSTLabelBreite}" Height="24" VerticalAlignment="Top" Content="{Binding Path=HJSTLabelContent}"></Label>

        <Label Width="5"></Label>

        <TextBox x:Name="Textbox1" Width="{Binding Path=HJSTTextboxBreite}" Style="{StaticResource ResourceKey=StyleTextBox}" Height="22">

            <Binding Path="HJSTTextboxText">

                <Binding.ValidationRules>

                    <local:MyValidationRules ValidatesOnTargetUpdated="true">

                        <local:MyValidationRules.Params >

                            <local:ValidationParams [COLOR="#FF0000"]ValidationType[/COLOR]="{Binding [COLOR="#FF0000"]HJSTValidationType[/COLOR]}"></local:ValidationParams>

                        </local:MyValidationRules.Params>

                    </local:MyValidationRules>

                </Binding.ValidationRules>

            </Binding>

        </TextBox>

    </WrapPanel>

</UserControl>

Nun zu den roten Markierungen:

- Gebe ich den ValidationType direkt an --> alles einwandfrei, Code reagiert wie gewünscht.

Ich möchte ihn aber als DependencyProperty angeben --> das Funktioniert nicht, kein Fehlermeldung

Ich habe zwar schon das ein oder andere gelesen aber die gefundenen Lösungen gehen nicht.

Was ich herausgefunden habe ist, dass ich das DependencyProperty scheinbar nicht im Zugriff habe (Datacontext) aber ich weiß auch nicht wie ich es angeben kann.

Hoffe auf eure Hilfe

Danke schonmal

Ich möchte ihn aber als DependencyProperty angeben --> das Funktioniert nicht, kein Fehlermeldung
Wenn das Binding fehlschlägt, sollte aber zumindest im Debug-Log eine Ausgabe zu sehen sein.

Hat deine UserControl-Klasse denn ein DependencyProperty HJSTValidationType?

  • Autor

Hallo

folgender Fehler kommt (den ich irgendwie übersehen hatte)

System.Windows.Data Error: 2 : Cannot find governing FrameworkElement or FrameworkContentElement for target element. BindingExpression:Path=HJSTValidationType; DataItem=null; target element is 'ValidationParams' (HashCode=39642524); target property is 'ValidationType' (type 'ValidationTypes')

Gruß Hans-Jörg

  • Autor

Hallo

das was ich probiert hatte, hatte schon immer ohne dass es mir aufgefallen ist "funktioniert" aber halt nicht komplett richtig.

Ich bekomme nun keinen Fehler mehr, ABER die Validierung wird "nur" überprüft, wenn ich in die Textbox erst einen Wert schreibe und danach wieder lösche und danach die Textbox verlasse.

Die ValidationRule prüft ob ein Wert drin steht oder nicht.

Gruß Hans-Jörg

Bearbeitet von HJST1979

  • Autor

Hallo

wie man den oberen Fehler wegbekommt, dass habe ich jetzt teilweise hinbekommen. Warum teilweise: Ich habe ein noch viel größeres "allgemeines" Problem festgestellt.

Ich arbeite ja auch für den Wert mit {Binding...} und DepencyProperty solange ich überhaupt keine ValidationRule habe kommen alle Informationen zum Ursprungsobjekt hin und zurück.

Sobald ich aber eine ValidationRule habe die auf einen Fehler läuft kommt nicht der aktuelle Wert im Ursprungsobjekt an, sondern der Programmablauf scheint irgendwie "abzubrechen". Dies bedeutet das der letzte "gültige" Wert im Ursprungsobjekt steht.

Mal sehen, wie ich das hinbekomme ;)

Gruß Hans-Jörg

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.