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.

[C# WPF XAML] dynamische Breite einer Textbox

Empfohlene Antworten

Hallo Forum.

Folgender Sachverhalt: Ich habe eine oberfläche mit XAML geschrieben.

Darin ist eine Listbox, für dessen Items ich ein Template gebaut habe.


<ListBox.ItemTemplate>

    <DataTemplate>

        <Border CornerRadius="6" Background="{Binding Color}" Margin="2">

            <StackPanel Orientation="Vertical">

                <StackPanel Orientation="Horizontal" MinWidth="235">

                    <TextBlock Text="{Binding UserName}" Margin="5,5,5,0" Foreground="LightGray"/>

                    <TextBlock Text="{Binding Date}" Margin="5,5,5,0" Foreground="LightGray"/>

                </StackPanel>

                <StackPanel Orientation="Horizontal" MinWidth="235">

                    <Image Source="{Binding ProfileImage}" Width="30" Height="30" Margin="5"/>

                    <TextBlock x:Name="Message" Text="{Binding Status}" Margin="5" Foreground="White" TextWrapping="Wrap" Width="200"/>

                </StackPanel>

            </StackPanel>

        </Border>

    </DataTemplate>

</ListBox.ItemTemplate>

Main Problem ist nun, dass ich das Textfeld "Message" dynamisch der Fensterbreite anpassen will, und dabei der Text automatisch umgebrochen werden soll (Umbruch geht schon). Also: Fensterbreite ändert sich -> darin enthaltene ListBox-Breite ändert sich -> ListItem-Breite ändert sich Ich habe es über alle Möglichen Einstellungen der Form
Width="{Binding ElementName=abc, Path=ActualWidth}"

probiert. (Natürlich hatte ich da noch ein Element abc.) Aber so richtig hinbekommen habe ich es nicht. Ich habe es nicht hinbekommen ein abc-Element (egal, ob Border, oder ein anderes TextFeld auf die richtige Größe zu pressen)

Hat einer eine Idee dazu?

Ich fange gerade erst mit WPF an, darum bitte ich um Verständniss, falls das Grundlagen sein sollten.

Danke, Philipp

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

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.