Click here to Skip to main content
16,004,991 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: Apply Styles To Custom Control Pin
Kevin Marois7-Jul-15 7:55
professionalKevin Marois7-Jul-15 7:55 
GeneralRe: Apply Styles To Custom Control Pin
Richard Deeming7-Jul-15 8:17
mveRichard Deeming7-Jul-15 8:17 
GeneralRe: Apply Styles To Custom Control Pin
Kevin Marois7-Jul-15 8:18
professionalKevin Marois7-Jul-15 8:18 
Questioncheck out of canvas Pin
ngthtra29-Jun-15 21:36
ngthtra29-Jun-15 21:36 
QuestionProblem in Show/Hide Control in a WPF User Control Pin
Ashfaque Hussain29-Jun-15 20:50
Ashfaque Hussain29-Jun-15 20:50 
AnswerRe: Problem in Show/Hide Control in a WPF User Control Pin
Richard Deeming30-Jun-15 1:10
mveRichard Deeming30-Jun-15 1:10 
GeneralRe: Problem in Show/Hide Control in a WPF User Control Pin
Ashfaque Hussain1-Jul-15 18:54
Ashfaque Hussain1-Jul-15 18:54 
QuestionHiding Few of control in UserControl Pin
Ashfaque Hussain26-Jun-15 0:16
Ashfaque Hussain26-Jun-15 0:16 
Questioni want make Online examination system so which module we used help me .and it work flow of the system Pin
Member 1178790023-Jun-15 18:38
Member 1178790023-Jun-15 18:38 
AnswerRe: i want make Online examination system so which module we used help me .and it work flow of the system Pin
Mycroft Holmes23-Jun-15 20:07
professionalMycroft Holmes23-Jun-15 20:07 
QuestionWPF Expander ExpandDirection Problem Pin
Kevin Marois22-Jun-15 12:56
professionalKevin Marois22-Jun-15 12:56 
AnswerRe: WPF Expander ExpandDirection Problem Pin
Pete O'Hanlon22-Jun-15 19:03
mvePete O'Hanlon22-Jun-15 19:03 
GeneralRe: WPF Expander ExpandDirection Problem Pin
Kevin Marois23-Jun-15 4:21
professionalKevin Marois23-Jun-15 4:21 
GeneralRe: WPF Expander ExpandDirection Problem Pin
Kevin Marois23-Jun-15 5:01
professionalKevin Marois23-Jun-15 5:01 
AnswerRe: WPF Expander ExpandDirection Problem Pin
maddymaddy1428-Jun-15 21:16
maddymaddy1428-Jun-15 21:16 
QuestionGlobal Exception Handling Pin
Kevin Marois19-Jun-15 12:24
professionalKevin Marois19-Jun-15 12:24 
QuestionRe: Global Exception Handling Pin
Richard Deeming22-Jun-15 1:23
mveRichard Deeming22-Jun-15 1:23 
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

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.