English 中文(简体)
如何确定模拟活动呼吁者
原标题:How to Identify Caller for Template Events

我有一份清单Box集装箱数据受约束并作相应调整:

    <ListBox x:Name="ListBox" 
             ItemsSource="{Binding Source={StaticResource List}}"
             ItemTemplate="{StaticResource ListTemplate}">
    </ListBox>

在我的名单上学生资源范围内,我界定了包含少数儿童内容的Grid。 我已就其中一名儿童建立了点击事件手。 活动手并非是专有的,我需要一种(最佳做法)的方法,确定在名单Box发生的事中哪一行。

从我的数据来源来看,我有一个与增长相对应的独特身份。 目前,我并没有在具有约束力的数据中披露这一身份。 理想的情况是,我祝愿会议各位手能够查明这次事件的发端人的身份。

问题回答

如果你能够向我们展示你的网格定义,以便更好地了解你的问题,那将是巨大的。

由于我的Grid s DataContext有我所需要的全部数据,我所做的是:

    private void NotificationLinkClick(object sender, RoutedEventArgs e)
    {
        var myDataObject = ((Hyperlink)sender).DataContext as MyDataObject;
        DoSomeWork(myDataObject);
    }

我的电网各行都有超链接。 为了知道选择了哪一个数据,如果是手稿,我会拿到数据目录,然后我把它带给我的基本对象。 我一去“一行”,就做我需要做的事情。

而且,正如安东尼建议的那样,我们可以使事情更加笼统。

    private void NotificationLinkClick(object sender, RoutedEventArgs e)
    {
        var myDataObject = ((FrameworkElement)sender)
                                             .DataContext as MyDataObject;
        DoSomeWork(myDataObject);
    }

I m pretty sure there s a better/cleaner way to do it, but this works. HTH





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签