【发布时间】:2015-12-03 17:29:24
【问题描述】:
我有一些开发 .NET Web 应用程序的经验,但现在我正在开发一个 Windows 应用程序。我无法理解 UI 组件。
特别是:有一个按钮(下图),其中只有文本是可点击的,并且希望将其更改为应用于整行(以蓝色突出显示)。
到目前为止,我发现点击文本会调用 UI 类中的一个函数,ProbeTree.xaml.cs:
public partial class ProbeTree : UserControl
{
private void StackPanel_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{ etc.. }
这个函数是从文件ProbeTree.g.i.cs中调用的:
void System.Windows.Markup.IStyleConnector.Connect(int connectionId, object target) {
switch (connectionId)
{
case 8:
#line 189 "..\..\..\..\UI\Protocol\ProbeTree.xaml"
((System.Windows.Controls.StackPanel)(target)).PreviewMouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.StackPanel_PreviewMouseLeftButtonDown);
#line default
#line hidden
break;
}
}
似乎在这个文件中我应该获得对整行的引用,并为其附加鼠标单击事件,而不是当前的target 参数。不幸的是,我在这里一无所知,并且由于No symbols have been loaded for this document,没有触发此文件上的断点。
最后ProbeTree.xaml 中的这段代码也是相关的:
<TreeView.Resources>
... many tags here ...
<DataTemplate DataType="{x:Type xs:VMReading}">
<StackPanel Orientation="Horizontal" DataContext="{Binding}" PreviewMouseLeftButtonDown="StackPanel_PreviewMouseLeftButtonDown">
<Label Content="{Binding Name}"></Label>
</StackPanel>
</DataTemplate>
</TreeView.Resources>
知道如何实现我的目标吗?
【问题讨论】:
标签: c# xaml user-interface windows-applications