Click here to Skip to main content
15,889,877 members
Home / Discussions / WPF
   

WPF

 
AnswerRe: the wpf added winform controls Pin
Pete O'Hanlon28-May-12 23:01
mvePete O'Hanlon28-May-12 23:01 
AnswerRe: the wpf added winform controls Pin
Cracked-Down29-May-12 0:36
Cracked-Down29-May-12 0:36 
QuestionDirectshow in silverlight Pin
ebrahim rajabloo28-May-12 3:16
ebrahim rajabloo28-May-12 3:16 
AnswerRe: Directshow in silverlight Pin
Abhinav S28-May-12 4:23
Abhinav S28-May-12 4:23 
GeneralRe: Directshow in silverlight Pin
ebrahim rajabloo28-May-12 17:41
ebrahim rajabloo28-May-12 17:41 
GeneralRe: Directshow in silverlight Pin
Pete O'Hanlon28-May-12 20:18
mvePete O'Hanlon28-May-12 20:18 
QuestionOperation could destabilize the runtime!!! Pin
ebrahim rajabloo26-May-12 22:19
ebrahim rajabloo26-May-12 22:19 
QuestionWPF HierarchicalDataTemplate Questions: Pin
Kevin Marois24-May-12 14:21
professionalKevin Marois24-May-12 14:21 
I have 2 questions...

I created a HierarchicalDataTemplate which is bound to a NodeModel

[Serializable]
public class NodeModel : ViewModelBase
{
    public Guid Id { get; set; }
    public string Caption { get; set; }
    public string Description { get; set; }
    public bool IsActive { get; set; }
    public ImageSource Image { get; set; }
    public bool IsExpanded { get; set; }
    public string FileName { get; set; }
    public NodeType Type { get; set; }
    public List<NodeModel> Children { get; set; }
}


the template:

<HierarchicalDataTemplate DataType="{x:Type models:NodeModel}"
                            ItemsSource="{Binding Path=Children}">
    <StackPanel Orientation="Horizontal"
                Margin="2">
            
        <Image Source="{Binding Image}"
                Height="16"
                Width="16"
                Margin="0,0,2,0" />

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

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

                    <Hyperlink.Style>     
                        <Style TargetType="Hyperlink">       
                            <Style.Triggers>         
                                <Trigger Property="IsMouseOver"
                                            Value="False">
                                    <Setter Property="TextDecorations"
                                            Value="{x:Null}" />         
                                </Trigger>       
                            </Style.Triggers>     
                        </Style>   
                    </Hyperlink.Style> 

                </Hyperlink>
                
                <TextBlock.ToolTip>
                    <ToolTip>
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>
                            <TextBlock FontWeight="Bold"
                                        Text="{Binding Path=Caption}"
                                        Grid.Row="0"
                                        Margin="0,0,0,3" />
                            <TextBlock FontStyle="Italic"
                                        Grid.Row="1"
                                        Text="{Binding Path=FileName}"
                                        Visibility="{Binding FileName, 
                                                    Converter={StaticResource StringToVisConverter}}" />
                            <TextBlock Text="{Binding Path=Description}"
                                        Grid.Row="2"
                                        Visibility="{Binding Description, 
                                                    Converter={StaticResource StringToVisConverter}}" />
                        </Grid>
                    </ToolTip>
                </TextBlock.ToolTip>
            </TextBlock>

    </StackPanel>

</HierarchicalDataTemplate>


Finally, the treeview this is used in:

<telerik:RadTreeView x:Name="tvwTreeData"
                     ItemsSource="{Binding Path=Folders}"
                     ItemContainerStyle="{StaticResource ItemContainerStyle}"
                     SelectedItem="{Binding Path=SelectedTreeItem, Mode=TwoWay}" />


Problem 1) When I click a hyperlink, the correct tree node is not always selected. In other words, to make it work right I have to click the node, then the hyperlink on that node. How can I adjust this so that clicking a link selects its node?

Problem 2) How can I adjust this template so that nodes of Type.Folder don't show the hyperlink?

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

AnswerRe: WPF HierarchicalDataTemplate Questions: Pin
Cracked-Down25-May-12 2:18
Cracked-Down25-May-12 2:18 
AnswerRe: WPF HierarchicalDataTemplate Questions: Pin
Cracked-Down25-May-12 7:33
Cracked-Down25-May-12 7:33 
GeneralRe: WPF HierarchicalDataTemplate Questions: Pin
Kevin Marois29-May-12 13:08
professionalKevin Marois29-May-12 13:08 
GeneralRe: WPF HierarchicalDataTemplate Questions: Pin
Cracked-Down29-May-12 18:55
Cracked-Down29-May-12 18:55 
GeneralRe: WPF HierarchicalDataTemplate Questions: Pin
Pete O'Hanlon29-May-12 22:27
mvePete O'Hanlon29-May-12 22:27 
QuestionHow to get to the top in wpf datagrid blank row? Pin
cengiz02624-May-12 10:19
cengiz02624-May-12 10:19 
AnswerRe: How to get to the top in wpf datagrid blank row? Pin
Mycroft Holmes24-May-12 12:43
professionalMycroft Holmes24-May-12 12:43 
QuestionCS6 Subscription and Creative Cloud Pin
Mark Walter Smith24-May-12 8:59
Mark Walter Smith24-May-12 8:59 
AnswerRe: CS6 Subscription and Creative Cloud Pin
Pete O'Hanlon24-May-12 9:15
mvePete O'Hanlon24-May-12 9:15 
QuestionLocalization in Silverlight Pin
Shirish kumar manda23-May-12 0:46
Shirish kumar manda23-May-12 0:46 
AnswerRe: Localization in Silverlight Pin
Abhinav S23-May-12 3:39
Abhinav S23-May-12 3:39 
Questionconvert byte to image Pin
heba abu ghaleih22 22-May-12 23:40
heba abu ghaleih22 22-May-12 23:40 
QuestionSilverlight 5 Pin
Mycroft Holmes22-May-12 22:29
professionalMycroft Holmes22-May-12 22:29 
AnswerRe: Silverlight 5 Pin
Abhinav S23-May-12 3:42
Abhinav S23-May-12 3:42 
GeneralRe: Silverlight 5 Pin
Mycroft Holmes23-May-12 13:05
professionalMycroft Holmes23-May-12 13:05 
QuestionTreeview & Listview Pin
rams221-May-12 7:07
rams221-May-12 7:07 
AnswerRe: Treeview & Listview Pin
Kevin Marois21-May-12 7:58
professionalKevin Marois21-May-12 7:58 

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.