Click here to Skip to main content
13,894,185 members

Silverlight / WPF

 
GeneralRe: Hyperlink Context Menu Pin
Kevin Marois10-Jan-19 5:31
professionalKevin Marois10-Jan-19 5:31 
QuestionTreeView Item Show Button Using Trigger Pin
Kevin Marois1-Jan-19 11:41
professionalKevin Marois1-Jan-19 11:41 
AnswerRe: TreeView Item Show Button Using Trigger Pin
Gerry Schmitz5-Jan-19 7:22
mveGerry Schmitz5-Jan-19 7:22 
GeneralRe: TreeView Item Show Button Using Trigger Pin
Kevin Marois7-Jan-19 7:31
professionalKevin Marois7-Jan-19 7:31 
GeneralRe: TreeView Item Show Button Using Trigger Pin
Gerry Schmitz7-Jan-19 8:39
mveGerry Schmitz7-Jan-19 8:39 
GeneralRe: TreeView Item Show Button Using Trigger Pin
Kevin Marois7-Jan-19 9:18
professionalKevin Marois7-Jan-19 9:18 
GeneralRe: TreeView Item Show Button Using Trigger Pin
J. Calhoun14-Feb-19 4:37
memberJ. Calhoun14-Feb-19 4:37 
QuestionWPF Items Source get the visible items Pin
Paul M Gibson31-Dec-18 7:00
memberPaul M Gibson31-Dec-18 7: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 6:42
mveGerry Schmitz1-Jan-19 6:42 
GeneralRe: WPF Items Source get the visible items Pin
Paul M Gibson2-Jan-19 6:22
memberPaul M Gibson2-Jan-19 6:22 
QuestionAd Control / monetization Pin
Super Lloyd18-Dec-18 13:02
memberSuper Lloyd18-Dec-18 13:02 
AnswerRe: Ad Control / monetization Pin
Pete O'Hanlon18-Dec-18 22:17
protectorPete O'Hanlon18-Dec-18 22:17 
GeneralRe: Ad Control / monetization Pin
Super Lloyd19-Dec-18 15:40
memberSuper Lloyd19-Dec-18 15:40 
AnswerRe: Ad Control / monetization Pin
Gerry Schmitz23-Dec-18 9:02
mveGerry Schmitz23-Dec-18 9:02 
GeneralRe: Ad Control / monetization Pin
Super Lloyd23-Dec-18 9:39
memberSuper Lloyd23-Dec-18 9:39 
GeneralRe: Ad Control / monetization Pin
Gerry Schmitz28-Dec-18 9:39
mveGerry Schmitz28-Dec-18 9:39 
QuestionValidation in WPF Pin
Kevin Marois18-Dec-18 6:59
professionalKevin Marois18-Dec-18 6:59 
AnswerRe: Validation in WPF Pin
Super Lloyd18-Dec-18 13:09
memberSuper Lloyd18-Dec-18 13:09 
AnswerRe: Validation in WPF Pin
Gerry Schmitz23-Dec-18 8:57
mveGerry Schmitz23-Dec-18 8:57 
QuestionI dont now what is the error "{"An ItemsControl is inconsistent with its items source.\n See the inner exception for more information."}" Pin
Rabee3-F1.78754516-Dec-18 2:01
memberRabee3-F1.78754516-Dec-18 2:01 
AnswerRe: I dont now what is the error "{"An ItemsControl is inconsistent with its items source.\n See the inner exception for more information."}" Pin
Super Lloyd16-Dec-18 15:50
memberSuper Lloyd16-Dec-18 15:50 
GeneralRe: I dont now what is the error "{"An ItemsControl is inconsistent with its items source.\n See the inner exception for more information."}" Pin
Rabee3-F1.78754517-Dec-18 10:22
memberRabee3-F1.78754517-Dec-18 10:22 
GeneralRe: I dont now what is the error "{"An ItemsControl is inconsistent with its items source.\n See the inner exception for more information."}" Pin
Super Lloyd17-Dec-18 15:28
memberSuper Lloyd17-Dec-18 15:28 
AnswerRe: I dont now what is the error "{"An ItemsControl is inconsistent with its items source.\n See the inner exception for more information."}" Pin
Richard Deeming17-Dec-18 9:20
mveRichard Deeming17-Dec-18 9:20 
QuestionI dont now what is the error "{"An ItemsControl is inconsistent with its items source.\n See the inner exception for more information."}" Pin
Rabee3-F1.78754516-Dec-18 1:34
memberRabee3-F1.78754516-Dec-18 1:34 

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
Web04 | 2.8.190306.1 | Last Updated 11 Mar 2019
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid