Click here to Skip to main content
15,867,756 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: Bubbling Event Question Pin
Kevin Marois16-May-23 7:02
professionalKevin Marois16-May-23 7:02 
QuestionExpander Header Content Stretch Pin
Kevin Marois9-May-23 11:25
professionalKevin Marois9-May-23 11:25 
AnswerRe: Expander Header Content Stretch Pin
Richard Deeming9-May-23 21:48
mveRichard Deeming9-May-23 21:48 
GeneralRe: Expander Header Content Stretch Pin
Kevin Marois13-May-23 6:05
professionalKevin Marois13-May-23 6:05 
QuestionVB.NET WPF drag and drop for LISTBOX and TREEVIEWs..Anyone help with examples? Pin
Member 84579549-May-23 8:51
Member 84579549-May-23 8:51 
AnswerRe: VB.NET WPF drag and drop for LISTBOX and TREEVIEWs..Anyone help with examples? Pin
Richard MacCutchan9-May-23 10:14
mveRichard MacCutchan9-May-23 10:14 
AnswerRe: VB.NET WPF drag and drop for LISTBOX and TREEVIEWs..Anyone help with examples? Pin
Richard Deeming9-May-23 21:38
mveRichard Deeming9-May-23 21:38 
QuestionListBoxItem DataTemplate with HyperLink Problem Pin
Kevin Marois8-May-23 11:52
professionalKevin Marois8-May-23 11:52 
I have a listbox bound to an entity called NavigationItemEntity which displays hyperlinks as the list items:
XAML
<ListBox x:Name="itemsList" 
            ItemsSource="{Binding Items, RelativeSource={RelativeSource TemplatedParent}}"
            ScrollViewer.HorizontalScrollBarVisibility="Auto"
            ScrollViewer.VerticalScrollBarVisibility="Auto"
            Margin="2"
            BorderBrush="Transparent"
            BorderThickness="0">

    <ListBox.ItemTemplate>
        <DataTemplate>

            <TextBlock>

                <local:MaroisHyperlink LinkText="{Binding Caption}">

                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="LinkClicked">
                            <i:InvokeCommandAction Command="{Binding RelativeSource={RelativeSource FindAncestor, 
                                                                        AncestorType={x:Type local:MaroisNavigationPane}}, 
                                                                        Path=ItemClickedCommand}"
                                                    CommandParameter="{Binding Path=SelectedItem,ElementName=itemsList}"/>
                        </i:EventTrigger>
                    </i:Interaction.Triggers>

                </local:MaroisHyperlink>

        </TextBlock>

        </DataTemplate>
    </ListBox.ItemTemplate>

</ListBox>
Code behind
private ICommand _ItemClickedCommand;
public ICommand ItemClickedCommand
{
    get
    {
        if (_ItemClickedCommand == null)
            _ItemClickedCommand = new RelayCommand<NavigationEntity>(p => ItemClickedExecuted(p), p => ItemClickedCanExecute(p));
        return _ItemClickedCommand;
    }
}

private bool ItemClickedCanExecute(NavigationEntity args)
{
    return true;
}

private void ItemClickedExecuted(NavigationEntity args)
{
    RaiseItemClickedEvent(args.Id, args.ItemType);
}

The problem is that if I first don't click the list item, but just the link, then the link is sent as the command parameter. If I first click the list item, THEN click the link, then entity is passed, which is what I want.

How can I force the list item to be selected when its link is clicked?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.

AnswerRe: ListBoxItem DataTemplate with HyperLink Problem Pin
Richard Deeming8-May-23 21:44
mveRichard Deeming8-May-23 21:44 
GeneralRe: ListBoxItem DataTemplate with HyperLink Problem Pin
Kevin Marois9-May-23 5:29
professionalKevin Marois9-May-23 5:29 
QuestionCustomControl Styling Question Pin
Kevin Marois4-May-23 17:22
professionalKevin Marois4-May-23 17:22 
AnswerRe: CustomControl Styling Question Pin
Pete O'Hanlon4-May-23 20:29
subeditorPete O'Hanlon4-May-23 20:29 
QuestionNavigationControl - Continued Pin
Kevin Marois2-May-23 14:49
professionalKevin Marois2-May-23 14:49 
AnswerRe: NavigationControl - Continued Pin
Richard Deeming2-May-23 22:19
mveRichard Deeming2-May-23 22:19 
GeneralRe: NavigationControl - Continued Pin
Kevin Marois3-May-23 5:21
professionalKevin Marois3-May-23 5:21 
GeneralRe: NavigationControl - Continued Pin
Kevin Marois3-May-23 15:10
professionalKevin Marois3-May-23 15:10 
GeneralRe: NavigationControl - Continued Pin
Richard Deeming3-May-23 21:35
mveRichard Deeming3-May-23 21:35 
QuestionWPF 3D rendering Pin
Kenneth Haugland1-May-23 4:52
mvaKenneth Haugland1-May-23 4:52 
AnswerRe: WPF 3D rendering Pin
Gerry Schmitz2-May-23 6:14
mveGerry Schmitz2-May-23 6:14 
GeneralRe: WPF 3D rendering Pin
Kenneth Haugland2-May-23 9:59
mvaKenneth Haugland2-May-23 9:59 
AnswerRe: WPF 3D rendering Pin
RedDk2-May-23 8:03
RedDk2-May-23 8:03 
GeneralRe: WPF 3D rendering Pin
Kenneth Haugland2-May-23 10:01
mvaKenneth Haugland2-May-23 10:01 
QuestionExpander in ListBoxItem Width Problem Pin
Kevin Marois27-Apr-23 7:19
professionalKevin Marois27-Apr-23 7:19 
AnswerRe: Expander in ListBoxItem Width Problem Pin
Richard Deeming1-May-23 23:09
mveRichard Deeming1-May-23 23:09 
GeneralRe: Expander in ListBoxItem Width Problem Pin
Kevin Marois2-May-23 7:12
professionalKevin Marois2-May-23 7:12 

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.