Click here to Skip to main content
13,836,654 members

Silverlight / WPF

 
PinnedHOW TO ANSWER A QUESTION PinPopular
Chris Maunder16-Jul-09 4:09
adminChris Maunder16-Jul-09 4:09 
PinnedHow to get an answer to your question PinPopular
Chris Maunder16-Jul-09 4:05
adminChris Maunder16-Jul-09 4:05 
QuestionHave two controls fill the MainWindow and resize automatically Pin
Mc_Topaz16-Jan-19 5:14
memberMc_Topaz16-Jan-19 5:14 
AnswerRe: Have two controls fill the MainWindow and resize automatically Pin
Richard Deeming16-Jan-19 9:07
mveRichard Deeming16-Jan-19 9:07 
GeneralRe: Have two controls fill the MainWindow and resize automatically Pin
Mc_Topaz16-Jan-19 20:22
memberMc_Topaz16-Jan-19 20:22 
QuestionHyperlink Context Menu Pin
Kevin Marois9-Jan-19 16:30
professionalKevin Marois9-Jan-19 16:30 
AnswerRe: Hyperlink Context Menu Pin
Richard Deeming10-Jan-19 1:32
mveRichard Deeming10-Jan-19 1:32 
GeneralRe: Hyperlink Context Menu Pin
Kevin Marois10-Jan-19 5:32
professionalKevin Marois10-Jan-19 5:32 
GeneralRe: Hyperlink Context Menu Pin
Kevin Marois10-Jan-19 6:31
professionalKevin Marois10-Jan-19 6:31 
QuestionTreeView Item Show Button Using Trigger Pin
Kevin Marois1-Jan-19 12:41
professionalKevin Marois1-Jan-19 12:41 
AnswerRe: TreeView Item Show Button Using Trigger Pin
Gerry Schmitz5-Jan-19 8:22
mveGerry Schmitz5-Jan-19 8:22 
GeneralRe: TreeView Item Show Button Using Trigger Pin
Kevin Marois7-Jan-19 8:31
professionalKevin Marois7-Jan-19 8:31 
GeneralRe: TreeView Item Show Button Using Trigger Pin
Gerry Schmitz7-Jan-19 9:39
mveGerry Schmitz7-Jan-19 9:39 
GeneralRe: TreeView Item Show Button Using Trigger Pin
Kevin Marois7-Jan-19 10:18
professionalKevin Marois7-Jan-19 10:18 
QuestionWPF Items Source get the visible items Pin
Paul M Gibson31-Dec-18 8:00
memberPaul M Gibson31-Dec-18 8:00 
I have a ScrollViewer with an ItemsSource that holds a user control. I need to know what the top visible item is in the scrollviewer at any given time, and I want my ViewModel to be able to react when the top item visible changes. I think that there is no built in functionality to do this, so perhaps I need to generate mouse down events in an attempt to select the topmost item, though I'd rather not have to do this.

here is the xaml for the top level stuff:

<ScrollViewer VerticalScrollBarVisibility="Auto" Grid.Column="0" Grid.Row="3" Grid.ColumnSpan="2" ScrollChanged="ScrollViewer_ScrollChanged">
            <ItemsControl x:Name="DivisionItems" ItemsSource="{Binding oObsByDiv}">
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <uc:ucObservationsHeader/>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
        </ScrollViewer>


The ObservationHeader user control maps to a category for each set of observations, and is this:

<UserControl x:Class="MOATools.Views.ucObservationsHeader"            

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"             

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"             

    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

    xmlns:uc="clr-namespace:MOATools.Views"

    mc:Ignorable="d" d:DesignHeight="115" d:DesignWidth="400">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="100"/>
            <ColumnDefinition Width="300*"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="20"/>
            <RowDefinition Height="100*"/>
        </Grid.RowDefinitions>
        <TextBox x:Name="divNum" Text="{Binding DivNum, Mode=OneWay}" Grid.Column="0" Grid.Row="0" Margin="0,3,0,0"/>
        <TextBox x:Name="divName" Text="{Binding DivName, Mode=OneWay}" Grid.Column="1" Grid.Row="0" Margin="0,3,0,0"/>
            <ItemsControl ItemsSource="{Binding lObs}" Grid.Row="1" Grid.Column="1">
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <uc:ucObservationsView/>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
    </Grid>
</UserControl>


Each observation header then has a list of observations mapped to the ObservationsView:

<UserControl x:Class="MOATools.Views.ucObservationsView"

             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 

             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 

             xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"

             mc:Ignorable="d" d:DesignHeight="75" d:DesignWidth="400">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="25"/>
            <RowDefinition Height="25*"/>
            <RowDefinition Height="25*"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width=".2*"/>
            <ColumnDefinition Width=".4*"/>
            <ColumnDefinition Width=".4*"/>
        </Grid.ColumnDefinitions>
        <TextBox x:Name="txtDivObs" HorizontalAlignment="Stretch" TextWrapping="Wrap" Text="{Binding obsFullNum, Mode=OneWay}" Grid.Column="0" Grid.Row="0"/>
        <Label x:Name="lblOpenDate" HorizontalAlignment="Left" Content="Open " Grid.Column="1" Grid.Row="0"/>
        <DatePicker x:Name="dtOpen" HorizontalAlignment="Right" SelectedDate="{Binding Opendate, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Grid.Column="1" Grid.Row="0"/>
        <Label x:Name="lblCLoseDate" HorizontalAlignment="Left" Content="Close " Grid.Column="2" Grid.Row="0"/>
        <DatePicker x:Name="txtCloseDate" HorizontalAlignment="Right" SelectedDate="{Binding Closedate}" Grid.Column="2" Grid.Row="0"/>
        <TextBox x:Name="txtDescription" HorizontalAlignment="Stretch" TextWrapping="Wrap" Text="{Binding Description}" VerticalAlignment="Top" Grid.ColumnSpan="3" Grid.Row="1"/>
        <TextBox x:Name="txtImagePath" HorizontalAlignment="Stretch" TextWrapping="Wrap" Text="{Binding ImagePath}" Grid.Row="2" Grid.ColumnSpan="3">
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="PreviewMouseLeftButtonUp">
                    <i:InvokeCommandAction Command="{Binding DataContext.PreviewImage, RelativeSource={RelativeSource AncestorType={x:Type Window}}}"

                                           CommandParameter="{Binding}"/>
                </i:EventTrigger>
            </i:Interaction.Triggers>
        </TextBox>
    </Grid>
</UserControl>



What I want is that as the user scrolls through the categories and observations, each time a new observation category hits the top of the window then a combo box that is bound to a list of the categories to be set to that category. This will make it easy for the user to enter a new observation by defaulting to the current category that they see in the window. I don't want them to have to first select the header or an observation because extra clicks like that are just bad design. But I can't find any way for the view to know anything about the items that are scrolled into view. The scroll viewer can give me a vertical scroll position, but it's not really correlated to the actual parent and child items in the datastructure. Is this possible?
AnswerRe: WPF Items Source get the visible items Pin
Gerry Schmitz1-Jan-19 7:42
mveGerry Schmitz1-Jan-19 7:42 
GeneralRe: WPF Items Source get the visible items Pin
Paul M Gibson2-Jan-19 7:22
memberPaul M Gibson2-Jan-19 7:22 
QuestionAd Control / monetization Pin
Super Lloyd18-Dec-18 14:02
memberSuper Lloyd18-Dec-18 14:02 
AnswerRe: Ad Control / monetization Pin
Pete O'Hanlon18-Dec-18 23:17
protectorPete O'Hanlon18-Dec-18 23:17 
GeneralRe: Ad Control / monetization Pin
Super Lloyd19-Dec-18 16:40
memberSuper Lloyd19-Dec-18 16:40 
AnswerRe: Ad Control / monetization Pin
Gerry Schmitz23-Dec-18 10:02
mveGerry Schmitz23-Dec-18 10:02 
GeneralRe: Ad Control / monetization Pin
Super Lloyd23-Dec-18 10:39
memberSuper Lloyd23-Dec-18 10:39 
GeneralRe: Ad Control / monetization Pin
Gerry Schmitz28-Dec-18 10:39
mveGerry Schmitz28-Dec-18 10:39 
QuestionValidation in WPF Pin
Kevin Marois18-Dec-18 7:59
professionalKevin Marois18-Dec-18 7:59 
AnswerRe: Validation in WPF Pin
Super Lloyd18-Dec-18 14:09
memberSuper Lloyd18-Dec-18 14:09 

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.


Advertise | Privacy | Cookies | Terms of Service
Web05 | 2.8.190114.1 | Last Updated 17 Jan 2019
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid