Click here to Skip to main content
15,887,350 members
Home / Discussions / WPF
   

WPF

 
AnswerRe: Global Exception Handling Pin
Kevin Marois22-Jun-15 3:50
professionalKevin Marois22-Jun-15 3:50 
GeneralRe: Global Exception Handling Pin
Richard Deeming22-Jun-15 3:55
mveRichard Deeming22-Jun-15 3:55 
GeneralRe: Global Exception Handling Pin
Kevin Marois22-Jun-15 3:56
professionalKevin Marois22-Jun-15 3:56 
AnswerRe: Global Exception Handling Pin
maddymaddy1428-Jun-15 23:39
maddymaddy1428-Jun-15 23:39 
QuestionWPF Register Controls Pin
Kevin Marois19-Jun-15 5:15
professionalKevin Marois19-Jun-15 5:15 
QuestionDual Range Slider Control Pin
Kevin Marois19-Jun-15 4:50
professionalKevin Marois19-Jun-15 4:50 
QuestionDual Thumb Slider Pin
Kevin Marois17-Jun-15 13:10
professionalKevin Marois17-Jun-15 13:10 
QuestionCalculate ListBoxItem Height Pin
Kevin Marois17-Jun-15 6:43
professionalKevin Marois17-Jun-15 6:43 
I need to set a ListBox's Items heights so that they fill the entire listbox:

In this window[^], everything below the splitter is my control. On the left is the listbox.

You can see there's open space below the last list item. It's ever more evident here[^]

Here's my XAML:
<ListBox Grid.Column="0"
            x:Name="categoryList"
            BorderBrush="LightGray"
            BorderThickness="0,0,1,0"
            ItemsSource="{Binding Categories}"
            ScrollViewer.VerticalScrollBarVisibility="Hidden"
            IsEnabled="False"
            Background="White"
            Width="100"
            Margin="0,-2,0,0">

<pre>
<ListBox.Style>
    <Style TargetType="{x:Type ListBox}">
        <Style.Triggers>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Background" Value="White" />
            </Trigger>
        </Style.Triggers>
    </Style>
</ListBox.Style>

<ListBox.ItemContainerStyle>
    <Style TargetType="{x:Type ListBoxItem}">
        <Setter Property="Height" Value="{Binding Path=DataContext.ListItemHeight, RelativeSource={RelativeSource AncestorType=Grid}}"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="BorderBrush" Value="LightGray"/>
        <Setter Property="BorderThickness" Value="0,0,0,1"/>
        <Style.Triggers>
            <Trigger Property="IsEnabled" Value="false">
                <Setter Property="Foreground" Value="SteelBlue"/>
                <Setter Property="Background" Value="White"/>
            </Trigger>
        </Style.Triggers>
    </Style>
</ListBox.ItemContainerStyle>

<ListBox.ItemTemplate>
    <DataTemplate>
        <TextBlock Text="{Binding CategoryName}"
                    VerticalAlignment="Center"
                    FontSize="16"
                    Margin="10,0,0,0"/>
    </DataTemplate>
</ListBox.ItemTemplate>





and the control's SizeChanged event:
private void sizeChanged(object sender, SizeChangedEventArgs e)
{
    ListItemHeight = Math.Floor(this.ActualHeight / (Categories.Count + 1));
}

What am I doing wrong here?

Thanks
If it's not broken, fix it until it is

AnswerRe: Calculate ListBoxItem Height Pin
Richard Deeming17-Jun-15 7:54
mveRichard Deeming17-Jun-15 7:54 
GeneralRe: Calculate ListBoxItem Height Pin
Kevin Marois17-Jun-15 8:07
professionalKevin Marois17-Jun-15 8:07 
QuestionFIPS Error Pin
#realJSOP11-Jun-15 3:41
mve#realJSOP11-Jun-15 3:41 
AnswerRe: FIPS Error Pin
Richard Deeming11-Jun-15 4:24
mveRichard Deeming11-Jun-15 4:24 
GeneralRe: FIPS Error Pin
#realJSOP11-Jun-15 4:42
mve#realJSOP11-Jun-15 4:42 
QuestionHow to get Data from web-server to Silverlight-App Pin
Frygreen10-Jun-15 10:31
Frygreen10-Jun-15 10:31 
AnswerRe: How to get Data from web-server to Silverlight-App Pin
Mycroft Holmes10-Jun-15 13:05
professionalMycroft Holmes10-Jun-15 13:05 
QuestionThoughts On Building My Own Framework Pin
Kevin Marois10-Jun-15 4:42
professionalKevin Marois10-Jun-15 4:42 
AnswerRe: Thoughts On Building My Own Framework Pin
Mycroft Holmes10-Jun-15 13:02
professionalMycroft Holmes10-Jun-15 13:02 
QuestionWPF Button Style quirks Pin
Bernhard Hiller3-Jun-15 2:55
Bernhard Hiller3-Jun-15 2:55 
AnswerRe: WPF Button Style quirks Pin
Richard Deeming3-Jun-15 3:22
mveRichard Deeming3-Jun-15 3:22 
GeneralRe: WPF Button Style quirks Pin
Bernhard Hiller3-Jun-15 3:34
Bernhard Hiller3-Jun-15 3:34 
QuestionWPF Window Closing Event To Command Pin
Kevin Marois2-Jun-15 13:12
professionalKevin Marois2-Jun-15 13:12 
QuestionRe: WPF Window Closing Event To Command Pin
Richard Deeming2-Jun-15 21:53
mveRichard Deeming2-Jun-15 21:53 
QuestionWPF Stream Live Video Pin
Kevin Marois1-Jun-15 13:56
professionalKevin Marois1-Jun-15 13:56 
AnswerRe: WPF Stream Live Video Pin
Pete O'Hanlon1-Jun-15 20:41
mvePete O'Hanlon1-Jun-15 20:41 
GeneralRe: WPF Stream Live Video Pin
Kevin Marois2-Jun-15 4:06
professionalKevin Marois2-Jun-15 4:06 

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.