datatemplate

Binding a WPF ComboBox to a different ItemsSource within a ListBox DataTemplate

狂风中的少年 提交于 2019-12-11 00:38:36
问题 I have a ListBox that contains a textbox and a combobox in its datatemplate: <ListBox Height="147" Margin="158,29,170,0" Name="PitcherListBox" VerticalAlignment="Top" ItemsSource="{Binding SomeCollectionOfObjects}" Background="Black"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> <TextBox Text="{Binding Path=Name}" /> <ComboBox ItemsSource="{Binding LocalArrayOfIntsProperty}" /> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> </ListBox> I want to bind the

Handling styling with data binding

◇◆丶佛笑我妖孽 提交于 2019-12-10 19:36:28
问题 REWRITTEN I have an application that receives a file. This file has a large amount of editable content. This content comes in a variety of possible types (i.e. boolean checkboxes, textboxes, etc). The issue is, these values can be either alone, or in a group (up to 8), so they come in arrays. We bind these values to a ListView , and use DataTemplates to display them. Effectively, I create the ListView from a list of arrays. The items in these arrays need to be data bound and styled properly

Combobox ItemTemplate and foreground

荒凉一梦 提交于 2019-12-10 19:28:41
问题 I have a comboBox that is bound to a list of strings from my viewModel. What I am trying to do is have the foreground of a comboBox item be set to a different color if a property in my viewModel is true: <ComboBox x:Name="myComboBox" ItemsSource="{Binding Names}"> <ComboBox.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding ...}"> <TextBlock.Style> <Style TargetType="{x:Type TextBlock}"> <Style.Triggers> <DataTrigger Binding="{Binding IsActive}" Value="True"> <Setter Property="Foreground"

using one data template in another data template in WPF

扶醉桌前 提交于 2019-12-10 18:33:09
问题 I have two data templates, one of which is the subset of another like below: <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:igEditors="http://infragistics.com/Editors" xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:controls="clr-namespace:Client.UI.WPF;assembly=Client.UI.WPF" xmlns:d="http://schemas.microsoft.com/expression/blend/2006" > <ResourceDictionary.MergedDictionaries>

Customize TabItem DataTemplate

老子叫甜甜 提交于 2019-12-10 15:13:23
问题 How can I make DataTemplate in WPF for TabItems and in each TabItem customize its content? I need this: <TabControl> <TabControl.ContentTemplate> <DataTemplate> <Label Content="Name" Name="label1" /> <TextBox Name="name" /> ... </DataTemplate> </TabControl.ContentTemplate> <TabItem Header="Add" Name="tabItem1"> <Grid Height="213"> <Button Content="Add" Name="button1" /> </Grid> </TabItem> <TabItem Header="Edit" Name="tabItem2"> <Grid> <Button Content="Edit" Name="button2" /> </Grid> </TabItem

Custom resource dictionary inside ControlTemplate or DataTemplate

强颜欢笑 提交于 2019-12-10 13:31:20
问题 EDIT: This problem occurs when using the standard .NET ResourceDictionary as well and appears to be an issue with using resource dictionaries inside control or data templates. I have a custom resource dictionary that follows a common approach to sharing resource instances. http://softnotes.wordpress.com/2011/04/05/shared-resourcedictionary-for-silverlight/ http://www.wpftutorial.net/MergedDictionaryPerformance.html public class SharedResourceDictionary : ResourceDictionary { static readonly

Filtering a hierarchical object displayed with nested xaml data templates

亡梦爱人 提交于 2019-12-10 12:52:46
问题 I'm having trouble filtering hierarchical data that's being displayed in nested xaml templates. I've got a ObservableCollection<Foo> Foos , that I'm displaying in XAML. Lets say Foo looks like: class Foo { public ObservableCollection<Bar> Bars; } class Bar { public ObservableCollection<Qux> Quxes; } I'm displaying Foos with the following xaml: <Grid> <Grid.Resources> <CollectionViewSource x:Key="MyCVS" Source="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type

Accessing DataGrid from DataTemplate (silverlight)

别说谁变了你拦得住时间么 提交于 2019-12-10 12:21:37
问题 WPF How to access control from DataTemplate In above example, the answers are all related to .Net solution. I am looking for similar solution for silverlight, it does not have FindName on Framework Template. My DataTemplate has a grid which I need to use to open the selecteditem on the grid. I currently have 4 grids which are placed using contentpresenter and since Silverlight does not support TemplateSelector I have visibility set to hide and show correct content presenter. Is there a way I

How do I bind to this custom dependency property?

不打扰是莪最后的温柔 提交于 2019-12-10 11:24:02
问题 I have a DependencyProperty in my custom UserControl that looks like this: public static readonly DependencyProperty ColumnWidthProperty = DependencyProperty.Register("ColumnWidth", typeof(int), typeof(CallBoard), new PropertyMetadata(150)); public int ColumnWidth { get { return (int)GetValue(ColumnWidthProperty); } set { SetValue(ColumnWidthProperty, value); } } In Expression Blend 3, I have this: <UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http:/

Datatemplate in c# code-behind

跟風遠走 提交于 2019-12-10 09:05:43
问题 I search an option to build a datatemplate in c# code. I had used : DataTemplate dt = new DataTemplate(typeof(TextBox)); Binding bind = new Binding(); bind.Path = new PropertyPath("Text"); bind.Mode = BindingMode.TwoWay; FrameworkElementFactory txtElement = new FrameworkElementFactory(typeof(TextBox)); txtElement.SetBinding(TextBox.TextProperty, bind); txtElement.SetValue(TextBox.TextProperty, "test"); dt.VisualTree = txtElement; textBox1.Resources.Add(dt, null); But it doesn't work (it is