Click here to Skip to main content
15,911,891 members
Home / Discussions / WPF
   

WPF

 
AnswerRe: tip for scrollviewer Pin
Christian Amado20-Jul-12 0:56
professionalChristian Amado20-Jul-12 0:56 
GeneralRe: tip for scrollviewer Pin
Pete O'Hanlon20-Jul-12 1:32
mvePete O'Hanlon20-Jul-12 1:32 
AnswerRe: tip for scrollviewer Pin
Christian Amado20-Jul-12 3:37
professionalChristian Amado20-Jul-12 3:37 
GeneralRe: tip for scrollviewer Pin
Pete O'Hanlon20-Jul-12 4:03
mvePete O'Hanlon20-Jul-12 4:03 
QuestionHow to open second page on click event Pin
Vikash Yadav16-Jul-12 23:15
Vikash Yadav16-Jul-12 23:15 
AnswerRe: How to open second page on click event Pin
maciej.tokarz17-Jul-12 3:01
maciej.tokarz17-Jul-12 3:01 
AnswerRe: How to open second page on click event Pin
Mycroft Holmes17-Jul-12 12:39
professionalMycroft Holmes17-Jul-12 12:39 
AnswerRe: How to open second page on click event Pin
Abhinav S17-Jul-12 16:01
Abhinav S17-Jul-12 16:01 
QuestionFruit Ninja sword effect Pin
wasimsharp15-Jul-12 6:27
wasimsharp15-Jul-12 6:27 
AnswerRe: Fruit Ninja sword effect Pin
Maximilien15-Jul-12 6:41
Maximilien15-Jul-12 6:41 
GeneralRe: Fruit Ninja sword effect Pin
wasimsharp15-Jul-12 6:44
wasimsharp15-Jul-12 6:44 
GeneralRe: Fruit Ninja sword effect Pin
Paul Conrad19-Jul-12 18:22
professionalPaul Conrad19-Jul-12 18:22 
QuestionWPF TreeView Style Pin
Kevin Marois13-Jul-12 10:07
professionalKevin Marois13-Jul-12 10:07 
AnswerRe: WPF TreeView Style Pin
Cracked-Down17-Jul-12 21:52
Cracked-Down17-Jul-12 21:52 
QuestionCall Web Service From Silverlight Application Pin
youness12-Jul-12 22:55
youness12-Jul-12 22:55 
AnswerRe: Call Web Service From Silverlight Application Pin
Pete O'Hanlon12-Jul-12 23:07
mvePete O'Hanlon12-Jul-12 23:07 
GeneralRe: Call Web Service From Silverlight Application Pin
youness13-Jul-12 5:23
youness13-Jul-12 5:23 
GeneralRe: Call Web Service From Silverlight Application PinPopular
Pete O'Hanlon15-Jul-12 11:13
mvePete O'Hanlon15-Jul-12 11:13 
GeneralRe: Call Web Service From Silverlight Application Pin
Mycroft Holmes16-Jul-12 0:34
professionalMycroft Holmes16-Jul-12 0:34 
GeneralRe: Call Web Service From Silverlight Application Pin
Pete O'Hanlon16-Jul-12 1:15
mvePete O'Hanlon16-Jul-12 1:15 
AnswerRe: Call Web Service From Silverlight Application Pin
Anumeha Shukla15-Jul-12 23:36
Anumeha Shukla15-Jul-12 23:36 
AnswerRe: Call Web Service From Silverlight Application Pin
vinodkrebc17-Jul-12 19:46
vinodkrebc17-Jul-12 19:46 
QuestionWPF Hyperlink In Treeview Problem Pin
Kevin Marois12-Jul-12 10:26
professionalKevin Marois12-Jul-12 10:26 
I'v been struggling with this all morning. Cold use some help...

I have created a HierarchicalDataTemplate used in a treeview. I have a class that overrides the basic treeview, called TreeViewEx, that I got from someone here at CP. (Can't remember who - sorry).

At any rate, here's the template:

<HierarchicalDataTemplate DataType="{x:Type models:TreeItemModel}"
                        ItemsSource="{Binding Path=Children}">
    <StackPanel Orientation="Horizontal"
            Margin="2">

        <TextBlock Margin="0,0,5,0">
            <Hyperlink NavigateUri="{Binding Caption}"
                        Foreground="#0C2DAA"
                        Style="{StaticResource linkStyle}"
                        Command="{Binding Path=DataContext.SelectedLinkCommand,
                                RelativeSource={RelativeSource FindAncestor, 
                                AncestorType={ x:Type views:MainWindowView}}}">

                <InlineUIContainer>
                    <TextBlock Text="{Binding Caption}" />
                </InlineUIContainer>

            </Hyperlink>

        </TextBlock>

    </StackPanel>

</HierarchicalDataTemplate>


and here's the treeview usage:

<controls:TreeViewEx ItemsSource="{Binding TreeItems}"/>


and finally the code behind:

private TreeItemModel _SelectedTreeLink;
public TreeItemModel SelectedTreeLink
{
    get { return _SelectedTreeLink; }
    set
    {
        if (_SelectedTreeLink != value)
        {
            _SelectedTreeLink = value;
            RaisePropertyChanged("SelectedTreeLink");
        }
    }
}

private ICommand _SelectedLinkCommand;
public ICommand SelectedLinkCommand
{
    get
    {
        if (_SelectedLinkCommand == null)
            _SelectedLinkCommand = new RelayCommand(SelectedLinkExecuted, SelectedLinkCanExecute);

        return _SelectedLinkCommand;
    }
}

private bool SelectedLinkCanExecute()
{
    return true;
}
private void SelectedLinkExecuted()
{
    var item = SelectedTreeLink;
}


The tree loads with data fine, and they tree nodes are hyperlinks. The command works. However, when I break in the SelectedLinkExecuted method, SelectedTreeLink = null.

How can I get a reference to the data model behind the link?

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

AnswerRe: WPF Hyperlink In Treeview Problem Pin
Ian Shlasko12-Jul-12 10:55
Ian Shlasko12-Jul-12 10:55 
GeneralRe: WPF Hyperlink In Treeview Problem Pin
Kevin Marois12-Jul-12 11:10
professionalKevin Marois12-Jul-12 11:10 

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.