是包含一个文本框可能一个按钮的概念? [英] Is this concept of a button containing a textbox possible?

查看:153
本文介绍了是包含一个文本框可能一个按钮的概念?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近,我一直在寻找一种方法,使标签在的TabControl 编辑和遇到的这个例子在Telerik的网站。这也正是我想要的,但它让我想到了一个按钮,类似的使用。我在想,如果说什么时候有可能使用类似的东西,使一个按钮,将显示一个文本框,而不是内容presenter,用鼠标右键单击该按钮?我试图使像这样的工作,但至今只结束了一个空白按钮。

Recently I had been looking for a way to make the tabs in a TabControl editable and came across This example on telerik's website. That did exactly what I wanted but it got me thinking about a similar usage for buttons. I was wondering if it would be possible to use something like that and make a button that would show a textbox instead of the content presenter when say, you right click the button? I tried to make something like this work but so far have only ended up with a blank button.

<Button x:Name="SB" Height="222" Width="222" Click="SB_Click">
    <ContentControl.ContentTemplate>
        <DataTemplate>
            <local:SuperButton Content="{Binding Path=x, Mode=TwoWay}"/>
        </DataTemplate>
    </ContentControl.ContentTemplate>
</Button>

其中x是(当然一类名称的改变,)一个字符串变量,并使用code从上面的链接后面。

Where x is a string variable and using the code behind from the link above (with a class name change, of course).

编辑:此按钮将是一个ItemsControl,所以我不认为命名在XAML将工作的内部元素,但我喜欢的难易程度沃尔夫冈的答案

edit: This button will be in an itemscontrol, so I don't think naming the inner elements in xaml will work, but I do like the ease of Wolfgang's answer.

推荐答案

的WPF内容模型 真的是灵活的,允许字面上的任何的里面的任何

这是完全有效的XAML:

This is perfectly valid XAML:

<Button>
    <TextBox/>
</Button>

甚至

<Button>
    <MediaElement Source="C:\Videos\WildLife.wmv"/>
</Button>

这篇关于是包含一个文本框可能一个按钮的概念?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆