Click here to Skip to main content
15,907,906 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: Need to dynamically size width of ListBox.ItemsPanel Pin
hb5213421422-Jan-10 7:33
hb5213421422-Jan-10 7:33 
GeneralRe: Need to dynamically size width of ListBox.ItemsPanel Pin
fjparisIII22-Jan-10 8:43
fjparisIII22-Jan-10 8:43 
GeneralRe: Need to dynamically size width of ListBox.ItemsPanel Pin
hb5213421422-Jan-10 9:45
hb5213421422-Jan-10 9:45 
GeneralRe: Need to dynamically size width of ListBox.ItemsPanel Pin
fjparisIII22-Jan-10 12:32
fjparisIII22-Jan-10 12:32 
GeneralRe: Need to dynamically size width of ListBox.ItemsPanel Pin
hb5213421422-Jan-10 13:55
hb5213421422-Jan-10 13:55 
GeneralRe: Need to dynamically size width of ListBox.ItemsPanel Pin
fjparisIII22-Jan-10 15:31
fjparisIII22-Jan-10 15:31 
GeneralRe: Need to dynamically size width of ListBox.ItemsPanel Pin
Kasim_Husaini20-Oct-10 20:02
Kasim_Husaini20-Oct-10 20:02 
GeneralRe: Need to dynamically size width of ListBox.ItemsPanel Pin
Gideon Engelberth22-Jan-10 12:46
Gideon Engelberth22-Jan-10 12:46 
The ScrollContentPresenter comes from the default template of ListBox (or more accurately, the ScrollViewer that a ListBox creates). The ScrollContentPresenter is the region inside a ScrollViewer that is not used by the scroll bars. When I first replied, I was rather hasty with the copy and paste of the WrapPanel. You really do not need several of those properties set.

<WrapPanel
    Name="wrapPanel"
    MinHeight="17"
    Width="{Binding ActualWidth,
                    RelativeSource=
                        {RelativeSource AncestorType={x:Type ScrollContentPresenter}}}"
    IsItemsHost="True"
    Orientation="Horizontal"
    HorizontalAlignment="Left"
    />


The Name is not useful because you won't be able to access the panel by name anyway. The IsItemsHost is ignored because it is already in the ItemsPanelTemplate. The default HorizontalAlignment is always what you end up wanting.

There are several possible reasons that come to mind for why the control is not sizing back down. One is that the when you are using the UserControl elsewhere, the sizing is not bound correctly and is thus only growing. Another option is that some other control in the the grid where you use this control is not sizing back down. If you are doing manual sizing in the code-behind somewhere else in the application where this control is used, that could be preventing the control from sizing back down. (In general, you should not have explicit sizes, except on windows, or mess with sizes in the code-behind in WPF. The automatic sizing should be able to handle most cases.) Some XAML from where this control is used may show the problem.

As a aside for design philosophy, does this UserControl do something special other than select horizontal wrap panel by default? If not, you would probably be better off defining a Style and applying it to any ListBox that you want to have this look and items panel. If you do leave this as a UserControl, you should take out the explicit ScrollViewer since the ListBox will create a ScrollViewer internally if needed.
GeneralRe: Need to dynamically size width of ListBox.ItemsPanel SOLVED! Pin
fjparisIII22-Jan-10 15:21
fjparisIII22-Jan-10 15:21 
GeneralRe: Need to dynamically size width of ListBox.ItemsPanel SOLVED! Pin
Gideon Engelberth22-Jan-10 19:14
Gideon Engelberth22-Jan-10 19:14 
QuestionPage loaded...but debug symbols not loaded? Need help ASAP please! Pin
Michael Eber21-Jan-10 9:03
Michael Eber21-Jan-10 9:03 
AnswerRe: Page loaded...but debug symbols not loaded? Need help ASAP please! Pin
Mark Salsbery21-Jan-10 13:52
Mark Salsbery21-Jan-10 13:52 
GeneralRe: Page loaded...but debug symbols not loaded? Need help ASAP please! Pin
Michael Eber21-Jan-10 19:05
Michael Eber21-Jan-10 19:05 
AnswerRe: Page loaded...but debug symbols not loaded? Need help ASAP please! Pin
Abhinav S21-Jan-10 19:24
Abhinav S21-Jan-10 19:24 
GeneralRe: Page loaded...but debug symbols not loaded? Need help ASAP please! Pin
Michael Eber22-Jan-10 12:43
Michael Eber22-Jan-10 12:43 
GeneralRe: Page loaded...but debug symbols not loaded? Need help ASAP please! Pin
Abhinav S22-Jan-10 20:52
Abhinav S22-Jan-10 20:52 
Questionisolated storage Pin
Tauseef A20-Jan-10 21:19
Tauseef A20-Jan-10 21:19 
AnswerRe: isolated storage Pin
Mark Salsbery21-Jan-10 5:37
Mark Salsbery21-Jan-10 5:37 
AnswerRe: isolated storage Pin
Abhinav S21-Jan-10 17:30
Abhinav S21-Jan-10 17:30 
AnswerRe: isolated storage Pin
fred_5-Feb-10 10:18
fred_5-Feb-10 10:18 
QuestionListView Style ? Pin
Mohammad Dayyan19-Jan-10 7:52
Mohammad Dayyan19-Jan-10 7:52 
AnswerRe: ListView Style ? Pin
AspDotNetDev19-Jan-10 21:02
protectorAspDotNetDev19-Jan-10 21:02 
QuestionGetting an Item Template to raise selected event properly Pin
Michael Eber19-Jan-10 6:04
Michael Eber19-Jan-10 6:04 
AnswerRe: Getting an Item Template to raise selected event properly Pin
Mark Salsbery19-Jan-10 6:23
Mark Salsbery19-Jan-10 6:23 
GeneralRe: Getting an Item Template to raise selected event properly Pin
Michael Eber19-Jan-10 6:29
Michael Eber19-Jan-10 6:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.