Autor
Nachricht
Andorxor
Mitglied
Benutzerprofil
Anmeldungsdatum: 01.02.2002
Beiträge: 981
Andorxor Mitglied
12:22:05 09.02.2010 Titel:
WPF:WrapPanel wrapt nicht
Zitieren
Ich habe ein WrapPanel in dem Content eines Expander der im ItemTemplate einer ListBox steht.Aber die Textblöcke im Wrappanel kommen nicht ein eine neue Zeile wenn ich die Liste mit einen GridSplitter zusammen schiebe.Stattdessen erscheint der Scrollbar der Liste.Hat einer eine Idee woran das liegen könnte?
HTML Code: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
<ListBox.ItemTemplate>
<DataTemplate>
<Expander ExpandDirection="Down " TextSearch.Text="{Binding Path=Kurzname} ">
<Expander.Header>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="* "/>
<ColumnDefinition Width="Auto "/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0 " Grid.Row="0 " Text="{Binding Path=Kurzname} " VerticalAlignment="Center " Margin="2 0 2 0 " HorizontalAlignment="Left "/>
<StackPanel HorizontalAlignment="Right " Grid.Column="1 " Grid.Row="0 " Orientation="Horizontal ">
<my:TelefonButton ToolTip="Anrufen "/>
<Button Padding="1 " Height="20 " Width="25 " Margin="2 0 2 0 " Click="OpenDetails_Click " ToolTip="Stammdaten ansehen ">
<Image Source="../Bilder/View.png "/>
</Button >
<Button Padding="1 " Height="20 " Width="25 " Margin="0 " Click="OpenKontakt_Click " ToolTip="Kontakt anlegen ">
<Image Source="../Bilder/Kontakt.png "/>
</Button >
</StackPanel>
</Grid>
</Expander.Header>
<Expander.Content>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto "/>
<RowDefinition Height="* "/>
</Grid.RowDefinitions>
<WrapPanel Grid.Row="0 " Orientation="Horizontal " VerticalAlignment="Stretch ">
<TextBlock Text="Name: " FontWeight="bold "/>
<TextBlock Text="{Binding Path=Name} " Margin="2 0 0 0 " />
<TextBlock Name="LabelGeburtstag " Text="Geburtstag: " FontWeight="bold " Margin="2 0 2 0 "/>
<TextBlock Name="DataGeburtstag " Text="{Binding Path=Geburtstag,StringFormat=dd.MM.yy} " Margin="2 0 2 0 " />
<TextBlock Name="LabelBranche " Visibility="Collapsed " Text="Branche: " FontWeight="bold " Margin="2 0 2 0 "/>
<TextBlock Name="DataBranche " Visibility="Collapsed " Text="{Binding Path=Branche} " Margin="2 0 2 0 " />
</WrapPanel>
<my:KommentarView Name="Kommentare " Grid.Row="1 "/>
</Grid>
</Expander.Content>
</Expander>
</DataTemplate>
</ListBox.ItemTemplate>
HTML Code: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
<ListBox.ItemTemplate>
<DataTemplate>
<Expander ExpandDirection="Down " TextSearch.Text="{Binding Path=Kurzname} ">
<Expander.Header>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="* "/>
<ColumnDefinition Width="Auto "/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0 " Grid.Row="0 " Text="{Binding Path=Kurzname} " VerticalAlignment="Center " Margin="2 0 2 0 " HorizontalAlignment="Left "/>
<StackPanel HorizontalAlignment="Right " Grid.Column="1 " Grid.Row="0 " Orientation="Horizontal ">
<my:TelefonButton ToolTip="Anrufen "/>
<Button Padding="1 " Height="20 " Width="25 " Margin="2 0 2 0 " Click="OpenDetails_Click " ToolTip="Stammdaten ansehen ">
<Image Source="../Bilder/View.png "/>
</Button >
<Button Padding="1 " Height="20 " Width="25 " Margin="0 " Click="OpenKontakt_Click " ToolTip="Kontakt anlegen ">
<Image Source="../Bilder/Kontakt.png "/>
</Button >
</StackPanel>
</Grid>
</Expander.Header>
<Expander.Content>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto "/>
<RowDefinition Height="* "/>
</Grid.RowDefinitions>
<WrapPanel Grid.Row="0 " Orientation="Horizontal " VerticalAlignment="Stretch ">
<TextBlock Text="Name: " FontWeight="bold "/>
<TextBlock Text="{Binding Path=Name} " Margin="2 0 0 0 " />
<TextBlock Name="LabelGeburtstag " Text="Geburtstag: " FontWeight="bold " Margin="2 0 2 0 "/>
<TextBlock Name="DataGeburtstag " Text="{Binding Path=Geburtstag,StringFormat=dd.MM.yy} " Margin="2 0 2 0 " />
<TextBlock Name="LabelBranche " Visibility="Collapsed " Text="Branche: " FontWeight="bold " Margin="2 0 2 0 "/>
<TextBlock Name="DataBranche " Visibility="Collapsed " Text="{Binding Path=Branche} " Margin="2 0 2 0 " />
</WrapPanel>
<my:KommentarView Name="Kommentare " Grid.Row="1 "/>
</Grid>
</Expander.Content>
</Expander>
</DataTemplate>
</ListBox.ItemTemplate>
HTML Code: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
<ListBox.ItemTemplate>
<DataTemplate>
<Expander ExpandDirection="Down " TextSearch.Text="{Binding Path=Kurzname} ">
<Expander.Header>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="* "/>
<ColumnDefinition Width="Auto "/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0 " Grid.Row="0 " Text="{Binding Path=Kurzname} " VerticalAlignment="Center " Margin="2 0 2 0 " HorizontalAlignment="Left "/>
<StackPanel HorizontalAlignment="Right " Grid.Column="1 " Grid.Row="0 " Orientation="Horizontal ">
<my:TelefonButton ToolTip="Anrufen "/>
<Button Padding="1 " Height="20 " Width="25 " Margin="2 0 2 0 " Click="OpenDetails_Click " ToolTip="Stammdaten ansehen ">
<Image Source="../Bilder/View.png "/>
</Button >
<Button Padding="1 " Height="20 " Width="25 " Margin="0 " Click="OpenKontakt_Click " ToolTip="Kontakt anlegen ">
<Image Source="../Bilder/Kontakt.png "/>
</Button >
</StackPanel>
</Grid>
</Expander.Header>
<Expander.Content>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto "/>
<RowDefinition Height="* "/>
</Grid.RowDefinitions>
<WrapPanel Grid.Row="0 " Orientation="Horizontal " VerticalAlignment="Stretch ">
<TextBlock Text="Name: " FontWeight="bold "/>
<TextBlock Text="{Binding Path=Name} " Margin="2 0 0 0 " />
<TextBlock Name="LabelGeburtstag " Text="Geburtstag: " FontWeight="bold " Margin="2 0 2 0 "/>
<TextBlock Name="DataGeburtstag " Text="{Binding Path=Geburtstag,StringFormat=dd.MM.yy} " Margin="2 0 2 0 " />
<TextBlock Name="LabelBranche " Visibility="Collapsed " Text="Branche: " FontWeight="bold " Margin="2 0 2 0 "/>
<TextBlock Name="DataBranche " Visibility="Collapsed " Text="{Binding Path=Branche} " Margin="2 0 2 0 " />
</WrapPanel>
<my:KommentarView Name="Kommentare " Grid.Row="1 "/>
</Grid>
</Expander.Content>
</Expander>
</DataTemplate>
</ListBox.ItemTemplate>
Zuletzt bearbeitet von Andorxor am 12:24:46 09.02.2010, insgesamt 1-mal bearbeitet
Firefighter
Mitglied
Benutzerprofil
Anmeldungsdatum: 27.03.2007
Beiträge: 2726
Firefighter Mitglied
12:34:21 09.02.2010 Titel:
Zitieren
Andorxor
Mitglied
Benutzerprofil
Anmeldungsdatum: 01.02.2002
Beiträge: 981
Andorxor Mitglied
12:44:09 09.02.2010 Titel:
Zitieren
Ich will nicht das innerhalb der Blöcke gewrapt wird,ich will das die Blöcke wrapen.Ausserdem brings nicht weil sowieso nur jeweils ein Wort in den verschiedenen Blöcken steht.
David W
Mitglied
Benutzerprofil
Anmeldungsdatum: 09.08.2005
Beiträge: 4588
David W Mitglied
13:46:03 09.02.2010 Titel:
Zitieren
Probiere mal folgendes (nur Pseudo):
C# Code: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto "/>
<RowDefinition Height="* "/>
</Grid.RowDefinitions>
<Grid x:Name="heightControl " />
<WrapPanel Grid.Row="0 " Orientation="Horizontal " Height="{Binding ActualHeight, ElementName=heightControl} ">
<TextBlock Text="Name: " FontWeight="bold "/>
<TextBlock Text="{Binding Path=Name} " Margin="2 0 0 0 " />
<TextBlock Name="LabelGeburtstag " Text="Geburtstag: " FontWeight="bold " Margin="2 0 2 0 "/>
<TextBlock Name="DataGeburtstag " Text="{Binding Path=Geburtstag,StringFormat=dd.MM.yy} " Margin="2 0 2 0 " />
<TextBlock Name="LabelBranche " Visibility="Collapsed " Text="Branche: " FontWeight="bold " Margin="2 0 2 0 "/>
<TextBlock Name="DataBranche " Visibility="Collapsed " Text="{Binding Path=Branche} " Margin="2 0 2 0 " />
</WrapPanel>
<my:KommentarView Name="Kommentare " Grid.Row="1 "/>
</Grid>
C# Code: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto "/>
<RowDefinition Height="* "/>
</Grid.RowDefinitions>
<Grid x:Name="heightControl " />
<WrapPanel Grid.Row="0 " Orientation="Horizontal " Height="{Binding ActualHeight, ElementName=heightControl} ">
<TextBlock Text="Name: " FontWeight="bold "/>
<TextBlock Text="{Binding Path=Name} " Margin="2 0 0 0 " />
<TextBlock Name="LabelGeburtstag " Text="Geburtstag: " FontWeight="bold " Margin="2 0 2 0 "/>
<TextBlock Name="DataGeburtstag " Text="{Binding Path=Geburtstag,StringFormat=dd.MM.yy} " Margin="2 0 2 0 " />
<TextBlock Name="LabelBranche " Visibility="Collapsed " Text="Branche: " FontWeight="bold " Margin="2 0 2 0 "/>
<TextBlock Name="DataBranche " Visibility="Collapsed " Text="{Binding Path=Branche} " Margin="2 0 2 0 " />
</WrapPanel>
<my:KommentarView Name="Kommentare " Grid.Row="1 "/>
</Grid>
C# Code: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto "/>
<RowDefinition Height="* "/>
</Grid.RowDefinitions>
<Grid x:Name="heightControl " />
<WrapPanel Grid.Row="0 " Orientation="Horizontal " Height="{Binding ActualHeight, ElementName=heightControl} ">
<TextBlock Text="Name: " FontWeight="bold "/>
<TextBlock Text="{Binding Path=Name} " Margin="2 0 0 0 " />
<TextBlock Name="LabelGeburtstag " Text="Geburtstag: " FontWeight="bold " Margin="2 0 2 0 "/>
<TextBlock Name="DataGeburtstag " Text="{Binding Path=Geburtstag,StringFormat=dd.MM.yy} " Margin="2 0 2 0 " />
<TextBlock Name="LabelBranche " Visibility="Collapsed " Text="Branche: " FontWeight="bold " Margin="2 0 2 0 "/>
<TextBlock Name="DataBranche " Visibility="Collapsed " Text="{Binding Path=Branche} " Margin="2 0 2 0 " />
</WrapPanel>
<my:KommentarView Name="Kommentare " Grid.Row="1 "/>
</Grid>
Wenn das funktioniert habe ich eine Passende Theorie
_________________My Libraries | aniwen
Andorxor
Mitglied
Benutzerprofil
Anmeldungsdatum: 01.02.2002
Beiträge: 981
Andorxor Mitglied
14:18:04 09.02.2010 Titel:
Zitieren
Das sorgt dafür das das WrapPanel verschwindet,aber die Weitenberechnung des Headers weiter beeinflusst.
Daher nehme ich an das das heightControl 0 hoch ist.
Zuletzt bearbeitet von Andorxor am 14:20:04 09.02.2010, insgesamt 1-mal bearbeitet
David W
Mitglied
Benutzerprofil
Anmeldungsdatum: 09.08.2005
Beiträge: 4588
David W Mitglied
16:02:03 09.02.2010 Titel:
Zitieren
Stimmt, da es mit Auto initialisiert wurde, habe da gerade nicht aufgepasst.
Initialisier es einfach mit einem Wert, durch den GridSplitter den du erwähntest (der aber nicht im Code ist) kannst du es auch verändern.
Die gesamte Problematik ist einfach, der ItemsPresentder der ListBox liegt in einem ScrollViewer, und dieser gibt den Child elementen immer Maximal platz, darum Wrappt er nicht.
Was auch gehen könnte ist wenn du den Horizontal Scroll Viewer der ListBox auf Disabled stellst.
ScrollViewer.HorizontalScrollBarVisibility="Disabled" als Attached Property
_________________My Libraries | aniwen
Zuletzt bearbeitet von David W am 16:04:29 09.02.2010, insgesamt 1-mal bearbeitet
Andorxor
Mitglied
Benutzerprofil
Anmeldungsdatum: 01.02.2002
Beiträge: 981
Andorxor Mitglied
09:16:54 10.02.2010 Titel:
Zitieren
Danke sehr.Es hat geklappt.
Nächstes Thema anzeigen
Vorheriges Thema anzeigen
Sie können Beiträge in dieses Forum schreiben. Sie können auf Beiträge in diesem Forum antworten. Sie können Ihre Beiträge in diesem Forum nicht bearbeiten. Sie können Ihre Beiträge in diesem Forum nicht löschen. Sie können an Umfragen in diesem Forum nicht mitmachen.