如何在不使用 DataContext 的情况下从代码隐藏绑定到资源
我有一个带有消息的数据网格,它已在代码隐藏中声明了 itemsource 。 我需要在每一行添加上下文菜单,用户可以从中选择他想要向其转发消息的用户。
<!-- COLUMN: DATE SENT -->
<data:DataGridTemplateColumn x:Name="DateSentColumn" CanUserSort="True"
SortMemberPath="DateSent" Width="80">
<data:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding DateSent, ConverterParameter=False, Converter={StaticResource cnvDate}}"
ToolTipService.ToolTip="{Binding DateSent, ConverterParameter=True, Converter={StaticResource cnvDate}}"
VerticalAlignment="Center"
FontWeight="{Binding IsBold, Converter={StaticResource cnvFontWeight}}"
Foreground="{Binding IsOverdueMessage, Converter={StaticResource cnvOverdue}}"
Margin="5,0,5,0">
<telerik:RadContextMenu.ContextMenu>
<telerik:RadContextMenu x:Name="inboxContextMenu" Opened="inboxContextMenu_Opened" ItemClick="inboxContextMenu_ItemClick">
<telerik:RadMenuItem x:Name="ForwardMessageMenuItem" Header="Forward message">
<telerik:RadMenuItem x:Name="SelectUserMenuItem"/>
</telerik:RadMenuItem>
</telerik:RadContextMenu>
</telerik:RadContextMenu.ContextMenu>
</TextBlock>
</DataTemplate>
</data:DataGridTemplateColumn.CellTemplate>
</data:DataGridTemplateColumn>
我不知道如何将用户绑定到 SelectUserMenuItem radmenuitem。
在代码后面我有一个属性 Users.
I have a datagrid with messages, which has declared itemsource in codebehind.
TO every row I need to add contextmenu from which user can select user to whom he wants forward a message.
<!-- COLUMN: DATE SENT -->
<data:DataGridTemplateColumn x:Name="DateSentColumn" CanUserSort="True"
SortMemberPath="DateSent" Width="80">
<data:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding DateSent, ConverterParameter=False, Converter={StaticResource cnvDate}}"
ToolTipService.ToolTip="{Binding DateSent, ConverterParameter=True, Converter={StaticResource cnvDate}}"
VerticalAlignment="Center"
FontWeight="{Binding IsBold, Converter={StaticResource cnvFontWeight}}"
Foreground="{Binding IsOverdueMessage, Converter={StaticResource cnvOverdue}}"
Margin="5,0,5,0">
<telerik:RadContextMenu.ContextMenu>
<telerik:RadContextMenu x:Name="inboxContextMenu" Opened="inboxContextMenu_Opened" ItemClick="inboxContextMenu_ItemClick">
<telerik:RadMenuItem x:Name="ForwardMessageMenuItem" Header="Forward message">
<telerik:RadMenuItem x:Name="SelectUserMenuItem"/>
</telerik:RadMenuItem>
</telerik:RadContextMenu>
</telerik:RadContextMenu.ContextMenu>
</TextBlock>
</DataTemplate>
</data:DataGridTemplateColumn.CellTemplate>
</data:DataGridTemplateColumn>
I don't know how can I bind users to SelectUserMenuItem radmenuitem.
In code behind I have a property Users.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论