Tag: datatemplate

使用数据模板(WPF)在ListBox中内联编辑TextBlock

使用WPF,我有一个ListBox控件,里面有一个DataTemplate 。 相关的XAML代码如下所示: 我想要做的是让TextBlock响应(双)单击,将其转换为TextBox 。 然后,用户可以编辑描述,然后按返回或更改焦点进行更改。 我尝试在与TextBlock相同的位置添加一个TextBox元素并使其可见性Collapsed ,但我不知道当用户单击TextBlock时如何导航到正确的TextBox 。 也就是说,我知道用户点击了某个TextBlock ,现在我显示哪个 TextBox ? 任何帮助将非常感激, -Ko9

样式化WPF ComboBox项目

我有一个非常简单的WPF应用程序,它显示一个ComboBox,它绑定到代表人的类列表。 每个’Person’对象都有一个Name字符串字段和一个Sex enum。 我希望ComboBox显示各种人物名称字段的下拉列表,但是根据性别字段对每一行进行样式设置,例如,蓝色表示男性,粉红色表示女性。 谁能告诉我我做错了什么? 这是XML: 这是C#: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using System.Collections.ObjectModel; namespace ComboBoxColour { /// /// Interaction logic for MainWindow.xaml /// public partial class MainWindow : Window { public List people; […]

如何访问Windows 8.1存储中的Hubsection Datatemplate内的任何控件

请告诉我如何在Hubsection * DataTemplate *中访问flipview控件

WPF ListView每行都有按钮

我有一个Games列表,它只有一个ID ,一个Date和一个Time 。 我将此列表设置为DataContext 。 然后,我为这些游戏准备了一个DataTemplate : //need to but a button here for each row 要使用模板,我只是这样做: 我需要在此列表视图中的每一行添加一个Button ,它具有相同的点击事件,但会以某种方式传递点击该按钮的游戏ID。 我怎样才能做到这一点? 我被卡住了。 如果它没有意义让我知道,我会尝试更好地解释。

如何更新ObservableCollection的现有元素?

我有一个ObservableCollection实例绑定到WPF列表框,其中包含两个独立的数据模板(一个用于显示,一个用于编辑)。 用于编辑的数据模板在文本框上具有单向绑定,并具有“保存”按钮。 我需要做哪些更改才能按下“保存”按钮(将列表项置于编辑模式后),值I更改文本框以替换ObservableCollection(和显示)中的值?

CompositeCollection + CollectionContainer:将CollectionContainer.Collection绑定到ViewModel的属性,该属性用作DataTemplates DataType

我没有获得正确的Binding语法来访问在其资源中定义CompositeCollection的MyViewModel中的DateTemplate的Cats and Dogs属性。 public class MyViewModel { public ObservableCollection Cats { get; private set; } public ObservableCollection Dogs { get; private set; } } 我要为????插入什么? 将Dogs and Cats集合绑定到CollectionContainer s?

在后面的代码中创建DataTemplate

如何以编程方式向datatemplates添加控件? 例如。 下面我创建了TextBlock和DataTemplate。 TextBlock text = new TextBlock(); DataTemplate template = new DataTemplate(); 现在我需要将TextBlock添加到DataTemplate。 怎么做到这一点? 我知道在代码中有addind数据模板的其他方法1.在XAML中创建数据模板并将其加载到后面的代码上2.使用XamlParser创建和添加 但我需要按照我在例子中展示的方式做。 需要一些帮助。