Search Results

Search found 603 results on 25 pages for 'datatemplate'.

Page 5/25 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • WPF TabItem Custom ContentTemplate

    - by lloydsparkes
    I have been strugging with this for a while, it would have been simple to do in WindowForms. I am making a IRC Client, there will be a number of Tabs one for each channel connect to. Each Tab needs to show a number of things, UserList, MessageHistory, Topic. In WindowForms i would just have inherited from TabItem, added some Custom Properties, and Controls, and done. In WPF i am having some slight issues with working out how to do it. I have tried many ways of doing it, and below is my current method, but i cannot get the TextBox to bind to the Topic Property. <Style TargetType="{x:Type t:IRCTabItem}" BasedOn="{StaticResource {x:Type TabItem}}" > <Setter Property="ContentTemplate"> <Setter.Value> <DataTemplate> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="540" /> <ColumnDefinition /> </Grid.ColumnDefinitions> <StackPanel Grid.Column="0"> <TextBox Text="{Binding Topic, RelativeSource={RelativeSource AncestorType={x:Type t:IRCTabItem}}}" /> </StackPanel> </Grid> </DataTemplate> </Setter.Value> </Setter> </Style> And the Codebehind public class IRCTabItem : TabItem { static IRCTabItem() { //This OverrideMetadata call tells the system that this element wants to provide a style that is different than its base class. //This style is defined in themes\generic.xaml //DefaultStyleKeyProperty.OverrideMetadata(typeof(IRCTabItem), // new FrameworkPropertyMetadata(typeof(IRCTabItem))); } public static readonly RoutedEvent CloseTabEvent = EventManager.RegisterRoutedEvent("CloseTab", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(IRCTabItem)); public event RoutedEventHandler CloseTab { add { AddHandler(CloseTabEvent, value); } remove { RemoveHandler(CloseTabEvent, value); } } public override void OnApplyTemplate() { base.OnApplyTemplate(); Button closeButton = base.GetTemplateChild("PART_Close") as Button; if (closeButton != null) closeButton.Click += new System.Windows.RoutedEventHandler(closeButton_Click); } void closeButton_Click(object sender, System.Windows.RoutedEventArgs e) { this.RaiseEvent(new RoutedEventArgs(CloseTabEvent, this)); } public bool Closeable { get; set; } public static readonly DependencyProperty CloseableProperty = DependencyProperty.Register("Closeable", typeof(bool), typeof(IRCTabItem), new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault)); public List<String> UserList { get; set; } public static readonly DependencyProperty UserListProperty = DependencyProperty.Register("UserList", typeof(List<String>), typeof(IRCTabItem), new FrameworkPropertyMetadata(new List<String>(), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault)); public String Topic { get; set; } public static readonly DependencyProperty TopicProperty = DependencyProperty.Register("Topic", typeof(String), typeof(IRCTabItem), new FrameworkPropertyMetadata("Not Connected", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault)); public bool HasAlerts { get; set; } public static readonly DependencyProperty HasAlertsProperty = DependencyProperty.Register("HasAlerts", typeof(bool), typeof(IRCTabItem), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault)); } So my questions are: Am i doing it the right way (best practices)? If so how can i bind DataTemplate to Properties? If not so, what is the correct way of achieve what i am trying to achieve?

    Read the article

  • WPF TextBox.SelectAll () doesn't work

    - by Zoliq
    Hi! I have used the following template in my project: <DataTemplate x:Key="textBoxDataTemplate"> <TextBox Name="textBox" ToolTip="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors)[0].ErrorContent}" Tag="{Binding}" PreviewKeyDown="cellValueTextBoxKeyDown"> <TextBox.Text> <MultiBinding Converter="{StaticResource intToStringMultiConverter}"> <Binding Path="CellValue" Mode="TwoWay"> <Binding.ValidationRules> <y:MatrixCellValueRule MaxValue="200" /> </Binding.ValidationRules> </Binding> <Binding RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type y:MatrixGrid}}" Path="Tag" Mode="OneWay" /> </MultiBinding> </TextBox.Text> </TextBox> </DataTemplate> I used this template to create an editable matrix for the user. The user is able to navigate from cell to cell within the matrix and I would like to highlight the data in the selected textbox but it doesn't work. I called TextBox.Focus () and TextBox.SelectAll () to achieve the effect but nothing. The Focus () works but the text never gets highlighted. Any help is welcome and appreciated.

    Read the article

  • WPF TabBarControl Setting Focus to element when tab changes

    - by Aran Mulholland
    I have a TabControl that is bound to a view model <TabControl ItemsSource="{Binding Path=ViewModelCollection}" > <TabControl.ItemContainerStyle> <Style TargetType="TabItem" BasedOn="{StaticResource {x:Type TabItem}}"> <Setter Property="Header" Value="{Binding Title}" /> <Setter Property="Content" Value="{Binding}" /> </Style> </TabControl.ItemContainerStyle> </TabControl> Each Tab simply contains a View Model Item. I use a data template to display this. <!-- View Model Template --> <DataTemplate DataType="{x:Type local:ViewModelItem}"> <DockPanel> <TextBox Text="I want this to have the focus"/> </DockPanel> </DataTemplate> When the current tab is changed i want the focus to be on the textbox (this is a simple example, in my production code i have a datagrid) in the data template. how do i accomplish this?

    Read the article

  • IValueConverter from string

    - by Aleksandar Toplek
    I have an Enum that needs to be shown in ComboBox. I have managed to get enum values to combobox using ItemsSource and I'm trying to localize them. I thought that that could be done using value converter but as my enum values are already strings compiler throws error that IValueConverter can't take string as input. I'm not aware of any other way to convert them to other string value. Is there some other way to do that (not the localization but conversion)? I'm using this marku extension to get enum values [MarkupExtensionReturnType(typeof (IEnumerable))] public class EnumValuesExtension : MarkupExtension { public EnumValuesExtension() {} public EnumValuesExtension(Type enumType) { this.EnumType = enumType; } [ConstructorArgument("enumType")] public Type EnumType { get; set; } public override object ProvideValue(IServiceProvider serviceProvider) { if (this.EnumType == null) throw new ArgumentException("The enum type is not set"); return Enum.GetValues(this.EnumType); } } and in Window.xaml <Converters:UserTypesToStringConverter x:Key="userTypeToStringConverter" /> .... <ComboBox ItemsSource="{Helpers:EnumValuesExtension Data:UserTypes}" Margin="2" Grid.Row="0" Grid.Column="1" SelectedIndex="0" TabIndex="1" IsTabStop="False"> <ComboBox.ItemTemplate> <DataTemplate DataType="{x:Type Data:UserTypes}"> <Label Content="{Binding Converter=userTypeToStringConverter}" /> </DataTemplate> </ComboBox.ItemTemplate> </ComboBox> And here is converter class, it's just a test class, no localization yet. public class UserTypesToStringConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { return (int) ((Data.UserTypes) value) == 0 ? "Fizicka osoba" : "Pravna osoba"; } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { return default(Data.UserTypes); } }

    Read the article

  • Retrieve a TextBox element dinamically created and Focus it

    - by user335444
    Hi, I have a collection (VariableValueCollection) of custom type VariableValueViewModel objects binded with a ListView. WPF Follow: <ListView ItemsSource="{Binding VariableValueCollection}" Name="itemList"> <ListView.Resources> <DataTemplate DataType="{x:Type vm:VariableValueViewModel}"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="180"></ColumnDefinition> </Grid.ColumnDefinitions> <TextBox TabIndex="{Binding Path=Index, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" Grid.Column="0" Name="tbValue" Focusable="True" LostFocus="tbValue_LostFocus" GotFocus="tbValue_GotFocus" KeyDown="tbValue_KeyDown"> <TextBox.Text> <Binding Path="Value" UpdateSourceTrigger="PropertyChanged" Mode="TwoWay"> <Binding.ValidationRules> <ExceptionValidationRule></ExceptionValidationRule> </Binding.ValidationRules> </Binding> </TextBox.Text> </TextBox> </Grid> </DataTemplate> </ListView.Resources> </ListView> My Goal is to add a new row when I press "enter" on last row, and Focus the new row. To do that, I check that row is the last row and add a new row in that case. But I don't know how to focus the new TextBox... Here the KeyPressed method: private void tbValue_KeyDown(object sender, KeyEventArgs e) { if (e.Key == System.Windows.Input.Key.Enter) { DependencyObject obj = itemList.ContainerFromElement((sender as TextBox)); int index = itemList.ItemContainerGenerator.IndexFromContainer(obj); if( index == (VariableValueCollection.Count - 1) ) { // Create a VariableValueViewModel object and add to collection. In binding, that create a new list item with a new TextBox ViewModel.AddNewRow(); // How to set cursor and focus last row created? } } } Thank's in advance...

    Read the article

  • DataTrigger not reevaluating after property changes

    - by frozen
    I have a listbox which has its itemssource (this is done in the code behind on as the window is created) databound to an observable collection. The List box then has the following data template assigned against the items: usercontrol.xaml ... <ListBox x:Name="communicatorListPhoneControls" ItemContainerStyle="{StaticResource templateForCalls}"/> ... app.xaml ... <Style x:Key="templateForCalls" TargetType="{x:Type ListBoxItem}"> <Setter Property="ContentTemplate" Value="{StaticResource templateRinging}"/> <Style.Triggers> <DataTrigger Binding="{Binding Path=hasBeenAnswered}" Value="True"> <Setter Property="ContentTemplate" Value="{StaticResource templateAnswered}"/> </DataTrigger> </Style.Triggers> </Style> ... When the observable collection is updated with an object, this appears in the listbox with the correct initial datatemplate, however when the "hasBeenAnswered" property is set to true (when debugging i can see the collection is correct) the datatrigger does not re-evaluate and then update the listbox to use the correct data template. I have implemented the INotifyPropertyChanged Event in my object, and if in the template i bind to a value, i can see the value update. Its just that the datatrigger will not re-evaluate and change to the correct template. I know the datatrigger binding is correct because if i close the window and open it again, it will correctly apply the second datatemplate, because the "hasBeenAnswered" is set to True.

    Read the article

  • Windows Phone 8 xaml textblock binding format

    - by user2042227
    I would like to format a textblock which is binded to a value, to show "R" before the actuall value, is this possible, cause I cannot directly change the value? Thank you <ListBox x:Name="lstbundleListbox" Foreground="White" Height="320" HorizontalAlignment="Center"> <ListBox.ItemContainerStyle> <Style TargetType="ListBoxItem"> <Setter Property="HorizontalContentAlignment" Value="Center" /> </Style> </ListBox.ItemContainerStyle> <ListBox.ItemTemplate> <DataTemplate> <StackPanel> <TextBlock Text="{Binding name}" TextWrapping="Wrap" HorizontalAlignment="Center"/> <TextBlock Text="{Binding cost}" TextWrapping="Wrap" HorizontalAlignment="Center"/> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <StackPanel Orientation="Vertical"/> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> </ListBox> So I basically want the texblock to show R(cost)

    Read the article

  • WPF data templates

    - by imekon
    I'm getting started with WPF and trying to get my head around connecting data to the UI. I've managed to connect to a class without any issues, but what I really want to do is connect to a property of the main window. Here's the XAML: <Window x:Class="test3.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:custom="clr-namespace:test3" Title="MainWindow" Height="350" Width="525"> <Window.Resources> <CollectionViewSource Source="{Binding Source={x:Static Application.Current}, Path=Platforms}" x:Key="platforms"/> <DataTemplate DataType="{x:Type custom:Platform}"> <StackPanel> <CheckBox IsChecked="{Binding Path=Selected}"/> <TextBlock Text="{Binding Path=Name}"/> </StackPanel> </DataTemplate> </Window.Resources> <Grid> <ListBox ItemsSource="{Binding Source={StaticResource platforms}}"/> </Grid> Here's the code for the main window: public partial class MainWindow : Window { ObservableCollection<Platform> m_platforms; public MainWindow() { m_platforms = new ObservableCollection<Platform>(); m_platforms.Add(new Platform("PC")); InitializeComponent(); } public ObservableCollection<Platform> Platforms { get { return m_platforms; } set { m_platforms = value; } } } Here's the Platform class: public class Platform { private string m_name; private bool m_selected; public Platform(string name) { m_name = name; m_selected = false; } public string Name { get { return m_name; } set { m_name = value; } } public bool Selected { get { return m_selected; } set { m_selected = value; } } } This all compiles and runs fine but the list box displays with nothing in it. If I put a breakpoint on the get method of Platforms, it doesn't get called. I don't understand as Platforms is what the XAML should be connecting to!

    Read the article

  • Silverlight RelativeSource of TemplatedParent Binding within a DataTemplate, Is it possible?

    - by Matt.M
    I'm trying to make a bar graph Usercontrol. I'm creating each bar using a DataTemplate. The problem is in order to compute the height of each bar, I first need to know the height of its container (the TemplatedParent). Unfortunately what I have: Height="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Height, Converter={StaticResource HeightConverter}, Mode=OneWay}" Does not work. Each time a value of NaN is returned to my Converter. Does RelativeSource={RelativeSource TemplatedParent} not work in this context? What else can I do to allow my DataTemplate to "talk" to the element it is being applied to? Incase it helps here is the barebones DataTemplate: <DataTemplate x:Key="BarGraphTemplate"> <Grid Width="30"> <Rectangle HorizontalAlignment="Center" Stroke="Black" Width="20" Height="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Height, Converter={StaticResource HeightConverter}, Mode=OneWay}" VerticalAlignment="Bottom" /> </Grid> </DataTemplate>

    Read the article

  • Why do I get a NullReferenceException when using a style on a ContentPresenter?

    - by Robert Rossney
    I've created this template, which uses a style applied to the ContentPresenter so that I can bind the data object's Column property to Grid.Column, allowing the items to determine for themselves which column of the Grid they go into: <DataTemplate DataType="{x:Type local:MyObject}"> <ItemsControl ItemsSource="{Binding Items}"> <ItemsControl.Resources> <Style TargetType="{x:Type ContentPresenter}"> <Setter Property="Grid.Column" Value="{Binding Column}" /> </Style> </ItemsControl.Resources> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="*" /> <ColumnDefinition Width="*" /> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> </Grid> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> </ItemsControl> </DataTemplate> When I run the program, I get a NullReferenceException. The beginning of the hilariously long stack trace: at System.Windows.StyleHelper.ApplyAutoAliasRules(OptimizedTemplateContent optimizedTemplateContent, HybridDictionary childIndexFromChildID, FrameworkTemplate frameworkTemplate, FrugalStructList`1& childRecordFromChildIndex, FrugalStructList`1& triggerSourceRecordFromChildIndex, FrugalStructList`1& resourceDependents, HybridDictionary& dataTriggerRecordFromBinding, Boolean& hasInstanceValues) at System.Windows.StyleHelper.ProcessTemplateContent(FrameworkTemplate frameworkTemplate, FrugalStructList`1& childRecordFromChildIndex, FrugalStructList`1& triggerSourceRecordFromChildIndex, FrugalStructList`1& resourceDependents, ItemStructList`1& eventDependents, HybridDictionary& dataTriggerRecordFromBinding, HybridDictionary childIndexFromChildID, Boolean& hasInstanceValues) at System.Windows.StyleHelper.SealTemplate(FrameworkTemplate frameworkTemplate, Boolean& isSealed, FrameworkElementFactory templateRoot, TriggerCollection triggers, ResourceDictionary resources, HybridDictionary childIndexFromChildID, FrugalStructList`1& childRecordFromChildIndex, FrugalStructList`1& triggerSourceRecordFromChildIndex, FrugalStructList`1& containerDependents, FrugalStructList`1& resourceDependents, ItemStructList`1& eventDependents, HybridDictionary& triggerActions, HybridDictionary& dataTriggerRecordFromBinding, Boolean& hasInstanceValues, EventHandlersStore& eventHandlersStore) at System.Windows.FrameworkTemplate.Seal() at System.Windows.StyleHelper.UpdateTemplateCache(FrameworkElement fe, FrameworkTemplate oldTemplate, FrameworkTemplate newTemplate, DependencyProperty templateProperty) at System.Windows.Controls.ContentPresenter.OnTemplateChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args) ...etc. It's not the binding. I still get the error if I explicitly set the value in the style's setter to 0, say. And the error vanishes if I remove the style, though then all of the items end up in column 0. What's going on here? And how do I debug a problem like this?

    Read the article

  • [WPF] SelectionChanged of a child ListBox

    - by quimbs
    Hi, I have a ListBox bound to an ObservableCollection with an ItemTemplate that contains another ListBox. First of all, I tried to get the last selected item of all the listboxes (either the parent and the inner ones) from my MainWindowViewModel this way: public object SelectedItem { get { return this.selectedItem; } set { this.selectedItem = value; base.NotifyPropertyChanged("SelectedItem"); } } So, for example, in the DataTemplate of the items of the parent ListBox I've got this: <ListBox ItemsSource="{Binding Tails}" SelectedItem="{Binding Path=DataContext.SelectedItem, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}"/> The problem now, is that when I select an item from the parent ListBox and then an item from a child listbox, I get this: http://i40.tinypic.com/j7bvig.jpg As you can see, two items are selected at the same time. How can I solve that? Thanks in advance.

    Read the article

  • WPF Accessing Items inside Listbox which has a UserControl as ItemTemplate

    - by Turker
    I have Window that has a ListBox ListBox(MyListBox) has a DataTable for its DataContext ListBox's ItemSource is : {Binding} Listbox has a UserControl(MyUserControl) as DataTemplate UserControl has RadioButtons and TextBoxes (At first They're filled with values from DataTable and then user can change them) Window has one Submit Button What I want to do is, when user clicks the submit button For each ListBox Item, get the values form UserControl's TextBoxes and RadioButtons. I was using that method for this job : foreach(var element in MyListBox.Items) { var border = MyListBox.ItemContainerGenerator.ContainerFromItem(element)as FrameworkElement; MyUserControl currentControl = VisualTreeHelper.GetChild(VisualTreeHelper.GetChild(VisualTreeHelper.GetChild(myBorder,0) as Border,0)as ContentPresenter,0)as MyUserControl; //And use currentControl } I realised nothing when using 3-5 items in Listbox. But when I used much more items, I saw that "var border" gets "null" after some elements looped in foreach function. I found the reason here : http://stackoverflow.com/questions/1675926/listview-itemcontainergenerator-containerfromitemitem-return-null-after-20-item So what can I do now? I want to access all items and get their values sitting on user controls. Thanks

    Read the article

  • WPF: HierarchicalDataTemplate ItemsPanel

    - by Echilon
    I have a TreeView which uses a custom ItemsPanel to show the first level of items in a StackPanel, but I need to show subitems in a StackPanel too. The problem is, the second level of items are shown in a WrapPanel, and as HierarchicalDataTemplate doesn't have an itemsPanel property I'm not sure how to do this. This is my xaml: <TreeView x:Name="treGlobalCards"> <TreeView.ItemsPanel> <ItemsPanelTemplate> <StackPanel IsItemsHost="True" Orientation="{Binding Orientation,RelativeSource={x:Static RelativeSource.TemplatedParent}}" MaxWidth="{Binding ActualWidth,RelativeSource={RelativeSource AncestorType={x:Type ScrollContentPresenter}}}"/> </ItemsPanelTemplate> </TreeView.ItemsPanel> <TreeView.ItemTemplate> <HierarchicalDataTemplate x:Key="CardTypeTemplate" ItemsSource="{Binding Cards}"> <TextBlock Text="{Binding Path=CardType}"/> </HierarchicalDataTemplate> </TreeView.ItemTemplate> </TreeView>

    Read the article

  • How to declare combobox itemTemplate that has Itemsource as Enum Values in WPF?

    - by Ashish Ashu
    I have a enum let's say enum MyEnum { FirstImage, SecondImage, ThirdImage, FourthImage }; I have binded this Enum to my combobox in XAML. While defining an combobox I have defined an ItemTemplate of combox to take Two UI element: TextBlock that show the enum value (Description) Image I have done this much in XAML. I am wondering where I can specify the Image corrosponding to each item of Enum value in a combobox? Is that possible through data trigger ? I really appreciate if anyone have the XAML for this scenario. Many Thanks in advance

    Read the article

  • Is it possible to template a template in WPF XAML?

    - by imekon
    Is it possible to use templates within templates? For instance, I have the following two templates: <HierarchicalDataTemplate x:Key="RecursiveTemplate" ItemsSource="{Binding Children}"> <StackPanel Margin="1" Orientation="Horizontal"> <Ellipse Fill="DarkGreen" Width="14" Height="14"/> <TextBlock MouseDown="OnTreeMouseDown" TargetUpdated="OnTargetUpdated" Visibility="{Binding Editing, Converter={StaticResource visibilityInverter}}" Margin="5" Text="{Binding Name}"/> <TextBox PreviewKeyDown="OnTreeKeyDown" Visibility="{Binding Editing, Converter={StaticResource visibilityConverter}}" Margin="2" Text="{Binding Name}"/> </StackPanel> </HierarchicalDataTemplate> <HierarchicalDataTemplate x:Key="ContainerTemplate" ItemsSource="{Binding Children}"> <StackPanel Margin="1" Orientation="Horizontal"> <Ellipse Fill="DarkBlue" Width="14" Height="14"/> <TextBlock MouseDown="OnTreeMouseDown" TargetUpdated="OnTargetUpdated" Visibility="{Binding Editing, Converter={StaticResource visibilityInverter}}" Margin="5" Text="{Binding Name}"/> <TextBox PreviewKeyDown="OnTreeKeyDown" Visibility="{Binding Editing, Converter={StaticResource visibilityConverter}}" Margin="2" Text="{Binding Name}"/> </StackPanel> </HierarchicalDataTemplate> There's a section of identical XAML: <TextBlock MouseDown="OnTreeMouseDown" TargetUpdated="OnTargetUpdated" Visibility="{Binding Editing, Converter={StaticResource visibilityInverter}}" Margin="5" Text="{Binding Name}"/> <TextBox PreviewKeyDown="OnTreeKeyDown" Visibility="{Binding Editing, Converter={StaticResource visibilityConverter}}" Margin="2" Text="{Binding Name}"/> Is it possible to move that to a resource and refer to it by name, rather than repeat it?

    Read the article

  • Hot to declare itemTemplate that has Itemsource as Enum Values in WPF?

    - by Ashish Ashu
    I have a enum let's say Enum MyEnum { FirstImage, SecondImage, ThirdImage, FourthImage }; I have binded this Enum to my combobox in XAML. While defining an combobox I have defined an ItemTemplate of combox to take Two UI element: TextBlock that show the enum value (Description) Image I have done this much in XAML. I am wondering where I can specify the Image corrosponding to each item of Enum. Is that possible through data trigger ? I really appreciate if anyone have the XAML for this scenario. Many Thanks in advance

    Read the article

  • WPF ItemsControl binding and the item order

    - by user109534
    I have ItemsControl in a WPF application, which is bind to an array of objects. And I am using ItemTemplate to render the list. I want to display for each item in the list the item order, like for example Customer 1 Name : xxxxx Age: 9999 Customer 2 Name : yyyy Age: 8888 Any idea how to do it Thanks

    Read the article

  • How to get relative source of item in ItemTemplate

    - by plotnick
    I have a ListBox with specified ItemTemplate. And the ItemTemplate contain itself ListView and I want to display in that ListView a collection, which is actually a property of the item of the ListBox. Could you show me how to do Binding. I'm thinking about RelativeSource thing, but I don't know what correct syntax would look like...

    Read the article

  • How to group consecutive similar items of a collection?

    - by CannibalSmith
    Consider the following collection. True False False False True True False False I want to display it in a structured way, say, in a TreeView. I want to be able to draw borders around entire groups and such. True Group True False Group False False False True Group True True False Group False False How do I accomplish this with as little procedural code as possible?

    Read the article

  • Select a data template by item type programatically in WPF

    - by Michael Stoll
    Hi all, unfortunately the WPF ToolbarTray does not support binding to a collection of ToolbarViewModels (Correct me, if I'm wrong). Thus I want to create the Toolbars programmatically. So there are two tasks, which I don't know how to do: Select the data template based on the item type. Instantiate the data template as toolbar Both should do the same as WPF does, when we use ItemsControl with an enumerable content and empty template. I used reflector to anaylse what WPF does. Task 1 is done by FrameworkElement.FindTemplateResourceInternal, but this is internal, and I couldn't find any public methods to acomplish the task. Of course one could enumerate all resources and match the data template data type property, but this seems sub-optimal. Who know's how to acomplish these tasks?

    Read the article

  • Binding Data Template element to property on sub-class

    - by TerrorAustralis
    Hi guys, I have a class, for experiment sake call it foo() and another class, call it bar() I have a data template for class foo() defined in my xaml, but one of foo()'s properties is a bar() object such that foo() { Public string Name {get; set;} Public int ID {get; set;} Public bar barProp {get; set;} } and bar() { Public string Description{get; set;} } I want my data template of foo to display the Description property of bar. I have tried the simple <textblock Text="{Binding Path=barProp.Description}" /> and variants to no avail Seeking wisdom, DJ

    Read the article

  • How can data templates in generic.xaml get applied automatically?

    - by Thiado de Arruda
    I have a custom control that has a ContentPresenter that will have an arbitrary object set as it content. This object does not have any constraint on its type, so I want this control to display its content based on any data templates defined by application or by data templates defined in Generic.xaml. If in a application I define some data template(without a key because I want it to be applied automatically to objects of that type) and I use the custom control bound to an object of that type, the data template gets applied automatically. But I have some data templates defined for some types in the generic.xaml where I define the custom control style, and these templates are not getting applied automatically. Here is the generic.xaml : If I set an object of type 'PredefinedType' as the content in the contentpresenter, the data template does not get applied. However, If it works if I define the data template in the app.xaml for the application thats using the custom control. Does someone got a clue? I really cant assume that the user of the control will define this data template, so I need some way to tie it up with the custom control.

    Read the article

  • Item rendered via a DataTemplate with any Background Brush renders selection coloring behind item.

    - by Mike L
    I have a ListBox which uses a DataTemplate to render databound items. The XAML for the datatemplate is as follows: <DataTemplate x:Key="NameResultTemplate"> <WrapPanel x:Name="PersonResultWrapper" Margin="0" Orientation="Vertical" Background="{Binding Converter={StaticResource NameResultToColor}, Mode=OneWay}" > <i:Interaction.Triggers> <i:EventTrigger EventName="MouseDown"> <cmd:EventToCommand x:Name="SelectPersonEventCommand" Command="{Binding Search.SelectedPersonCommand, Mode=OneWay, Source={StaticResource Locator}}" CommandParameter="{Binding Mode=OneWay}" /> </i:EventTrigger> </i:Interaction.Triggers> <TextBlock x:Name="txtPersonName" TextWrapping="Wrap" Margin="0" VerticalAlignment="Top" Text="{Binding PersonName}" FontSize="24" Foreground="Black" /> <TextBlock x:Name="txtAgencyName" TextWrapping="Wrap" Text="{Binding AgencyName}" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="0" FontStyle="Italic" Foreground="Black" /> <TextBlock x:Name="txtPIDORI" TextWrapping="Wrap" Text="{Binding PIDORI}" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="0" FontStyle="Italic" Foreground="Black" /> <TextBlock x:Name="txtDescriptors" TextWrapping="Wrap" Text="{Binding DisplayDescriptors}" Margin="0" VerticalAlignment="Top" Foreground="Black"/> <Separator Margin="0" Width="400" /> </WrapPanel> </DataTemplate> Note that there is a value converter called NameResultToColor which changes the background brush of the rendered WrapPanel to gradient brush depending on certain scenarios. All of this works as I'd expect, except when you click on any of the rendered ListBox items. When you click one, there is only the slightest sign of the selection coloring (the default bluish color). I can see a trace bit of it underneath my gradient-brushed item. If I reset the background brush to "no brush" then the selection rendering works properly. If I set the background brush to a solid color, it also fails to render as I'd expect. How can I get the selection coloring to be on top? What is trumping the selection rendering?

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >