RibbonSplitButton点击事件

发布于 2024-11-28 21:19:05 字数 752 浏览 1 评论 0原文

绅士,

我正在将一个集合绑定到 RibbonSplitButton (基本上,显示 3 个值:红色、绿色、蓝色) 除了我必须弄清楚选择了哪种颜色(项目)的问题之外,一切正常:

这是我的代码:

<r:RibbonSplitButton Name="TagEm" 
    LargeImageSource="Images\pencil_32.png"
    Label="Tag"
    ItemsSource="{Binding Path=TagCollection}"
    Click="TagEm_Click">
    <r:RibbonSplitButton.ItemTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding Descr}" />
        </DataTemplate>
    </r:RibbonSplitButton.ItemTemplate>
</r:RibbonSplitButton>

代码后面:

private void TagEm_Click(object sender, RoutedEventArgs e)
{
}

类似(Tag)TagEm.Items.CurrentItem

有人可以给我提示吗?

非常感谢!

N。

Gentelman,

I'm binding a collection to RibbonSplitButton (basically, showing 3 values: red, green, blue) Everything works fine except of the problem I have to figure out which color (item) has been chosen:

Here's my code:

<r:RibbonSplitButton Name="TagEm" 
    LargeImageSource="Images\pencil_32.png"
    Label="Tag"
    ItemsSource="{Binding Path=TagCollection}"
    Click="TagEm_Click">
    <r:RibbonSplitButton.ItemTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding Descr}" />
        </DataTemplate>
    </r:RibbonSplitButton.ItemTemplate>
</r:RibbonSplitButton>

Code behind:

private void TagEm_Click(object sender, RoutedEventArgs e)
{
}

Something like (Tag)TagEm.Items.CurrentItem;

Could someone give me a hint, please?

Many thanks in advance!

N.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

超可爱的懒熊 2024-12-05 21:19:06

不要使用 RibbonSplitButton Click 事件。请改用 TextBox MouseLeftButtonUp 事件。

XAML:

<r:RibbonSplitButton
    Name="TagEm"
    LargeImageSource="Images\pencil_32.png"     
    Label="Tag"     
    ItemsSource="{Binding Path=TagCollection}">
    <r:RibbonSplitButton.ItemTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding}" MouseLeftButtonUp="TextBlock_MouseLeftButtonUp" />
        </DataTemplate>
    </r:RibbonSplitButton.ItemTemplate>
</r:RibbonSplitButton>

事件处理程序:

private void TextBlock_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
    Tag clickedTag = (sender as TextBlock).DataContext as Tag;
}

Do not use the RibbonSplitButton Click event. Instead use the TextBox MouseLeftButtonUp event.

XAML:

<r:RibbonSplitButton
    Name="TagEm"
    LargeImageSource="Images\pencil_32.png"     
    Label="Tag"     
    ItemsSource="{Binding Path=TagCollection}">
    <r:RibbonSplitButton.ItemTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding}" MouseLeftButtonUp="TextBlock_MouseLeftButtonUp" />
        </DataTemplate>
    </r:RibbonSplitButton.ItemTemplate>
</r:RibbonSplitButton>

Event Handler:

private void TextBlock_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
    Tag clickedTag = (sender as TextBlock).DataContext as Tag;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文