Click here to Skip to main content
15,887,880 members
Home / Discussions / WPF
   

WPF

 
QuestionOCR using Microsoft Office Document Imaging 12.0 Type Library in WPF application Pin
Member 785476914-May-14 20:20
Member 785476914-May-14 20:20 
AnswerRe: OCR using Microsoft Office Document Imaging 12.0 Type Library in WPF application Pin
AlphaDeltaTheta15-May-14 16:48
AlphaDeltaTheta15-May-14 16:48 
QuestionSilverlight: Exception with ListBox and nested collection Pin
tongo7612-May-14 23:01
tongo7612-May-14 23:01 
AnswerRe: Silverlight: Exception with ListBox and nested collection Pin
Mycroft Holmes13-May-14 12:56
professionalMycroft Holmes13-May-14 12:56 
QuestionWPF Generate Dynamic Messages Including Links Pin
Kevin Marois6-May-14 16:44
professionalKevin Marois6-May-14 16:44 
AnswerRe: WPF Generate Dynamic Messages Including Links Pin
Bernhard Hiller6-May-14 20:58
Bernhard Hiller6-May-14 20:58 
QuestionCreating multilanguage WPF MVVM application Pin
sifi mohamed amine2-May-14 4:43
sifi mohamed amine2-May-14 4:43 
QuestionMultiBinding Question Pin
Kevin Marois1-May-14 14:32
professionalKevin Marois1-May-14 14:32 
I have a treeview bound to a collection of Employees. Each Employee has one or more HoursWorked entity in a property called HoursWorked.

The HierarchicalDataTemplate has an Add button in it to add a new Hours Worked node under it.

Each hours worked node DataTemplate has a Remove button next to it. When it's clicked I'd like to pass both the Employee and the HoursWorked entity.

So I have:

<!--Employee-->
<HierarchicalDataTemplate DataType="{x:Type models:WorkDoneEmployeeInfoModel}"
							ItemsSource="{Binding HoursWorked}">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="60"/>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="Auto"/>
        </Grid.ColumnDefinitions>
        <TextBlock Grid.Column="0"
                    Text="Employee:"
                    VerticalAlignment="Center"
                    FontWeight="Bold"/>
        <TextBlock Grid.Column="1" 
                    VerticalAlignment="Center"
                    Text="{Binding EmployeeName}"/>
        <Button Grid.Column="2" 
                Command="{Binding RelativeSource={RelativeSource AncestorType={x:Type UserControl},Mode=FindAncestor},Path=DataContext.AddHoursCommand}"
                CommandParameter="{Binding}"
                VerticalAlignment="Center"
                Height="22"
                Width="22"
                Margin="10,3,3,3">
            <Image Source="/FMG.UI.WPF.Shared;component/Media/Images/add_256.png"
                    Height="16"
                    Width="16"/>
        </Button>
    </Grid>
</HierarchicalDataTemplate>

<!--Hours Worked-->
<DataTemplate DataType="{x:Type models:WorkDoneHoursWorkedModel}">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="100"/>
            <ColumnDefinition Width="250"/>
            <ColumnDefinition Width="100"/>
            <ColumnDefinition Width="250"/>
            <ColumnDefinition Width="Auto"/>
        </Grid.ColumnDefinitions>
        <TextBlock Grid.Column="0"
                    Text="Time In:"
                    VerticalAlignment="Center"
                    FontWeight="Bold"/>
        <TextBlock Grid.Column="1" 
                    VerticalAlignment="Center"
                    Text="{Binding WorkStartDateTime}"/>
        <TextBlock Grid.Column="2"
                    VerticalAlignment="Center"
                    Text="Time Out:"
                    FontWeight="Bold"/>
        <TextBlock Grid.Column="3" 
                    VerticalAlignment="Center"
                    Text="{Binding WorkEndDateTime}"/>
        <Button Grid.Column="3" 
                Command="{Binding RelativeSource={RelativeSource AncestorType={x:Type UserControl},Mode=FindAncestor},Path=DataContext.SubtractHoursCommand}"
                VerticalAlignment="Center"
                Height="22"
                Width="22"
                Margin="10,3,3,3">

            <Button.CommandParameter>
                <MultiBinding Converter="{StaticResource MyMultiConverter}">

                    <!--The EmplyeeEntity-->
                    <Binding Path=""/>                                     <===== WHAT GOES HERE? ===========

                    <!--The HoursWorked entity-->
                    <Binding Path="{Binding}"/>
                </MultiBinding>
            </Button.CommandParameter>

            <Image Source="/FMG.UI.WPF.Shared;component/Media/Images/subtract_256.png"
                    Height="16"
                    Width="16"/>
        </Button>
    </Grid>
</DataTemplate >


So in the bottom template, I am passing the WoursWorked entity, but how do I set up the XAML to pass the parent node?

Thank you


[EDIT - RESOLVED]
<Button.CommandParameter>
    <MultiBinding Converter="{StaticResource multiValueConverter}">
        <Binding RelativeSource="{RelativeSource AncestorType={x:Type TreeViewItem}, AncestorLevel=2}"/>
        <Binding RelativeSource="{RelativeSource AncestorType={x:Type TreeViewItem}, AncestorLevel=1}"/>
    </MultiBinding>
</Button.CommandParameter>

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


modified 2-May-14 18:04pm.

QuestionUpdate Instance Property From DP Pin
Kevin Marois29-Apr-14 6:29
professionalKevin Marois29-Apr-14 6:29 
AnswerRe: Update Instance Property From DP Pin
Richard Deeming29-Apr-14 6:34
mveRichard Deeming29-Apr-14 6:34 
GeneralRe: Update Instance Property From DP Pin
Kevin Marois29-Apr-14 6:37
professionalKevin Marois29-Apr-14 6:37 
QuestionWPF Style Question Pin
Kevin Marois28-Apr-14 7:18
professionalKevin Marois28-Apr-14 7:18 
AnswerRe: WPF Style Question Pin
Pete O'Hanlon28-Apr-14 7:24
mvePete O'Hanlon28-Apr-14 7:24 
GeneralRe: WPF Style Question Pin
Kevin Marois28-Apr-14 7:27
professionalKevin Marois28-Apr-14 7:27 
GeneralRe: WPF Style Question Pin
Pete O'Hanlon28-Apr-14 8:09
mvePete O'Hanlon28-Apr-14 8:09 
AnswerRe: WPF Style Question Pin
pradeep surya10-May-14 5:37
pradeep surya10-May-14 5:37 
QuestionPass Logging Method Pin
Kevin Marois24-Apr-14 12:01
professionalKevin Marois24-Apr-14 12:01 
AnswerRe: Pass Logging Method Pin
Matt T Heffron24-Apr-14 12:49
professionalMatt T Heffron24-Apr-14 12:49 
QuestionWPF TextBlock Trigger Question Pin
Kevin Marois24-Apr-14 7:45
professionalKevin Marois24-Apr-14 7:45 
AnswerRe: WPF TextBlock Trigger Question Pin
Richard Deeming24-Apr-14 8:24
mveRichard Deeming24-Apr-14 8:24 
GeneralRe: WPF TextBlock Trigger Question Pin
Kevin Marois24-Apr-14 8:53
professionalKevin Marois24-Apr-14 8:53 
GeneralRe: WPF TextBlock Trigger Question Pin
BubingaMan4-May-14 22:48
BubingaMan4-May-14 22:48 
QuestionI need develop Deepzoom fitBounds Method Pin
joajngwon23-Apr-14 19:58
joajngwon23-Apr-14 19:58 
QuestionWPF MVVM Set Focus Pin
Kevin Marois23-Apr-14 17:46
professionalKevin Marois23-Apr-14 17:46 
QuestionChange application language at Runtime Pin
sifi mohamed amine15-Apr-14 5:40
sifi mohamed amine15-Apr-14 5:40 

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.