Search Results

Search found 58 results on 3 pages for 'itemsource'.

Page 1/3 | 1 2 3  | Next Page >

  • dropdownlist itemsource and selected value in wpf

    - by vahid
    hi all i have a dropdownlist that bind to a collection of all system colors(ObjectDataProvider).it shows colors name and background of each items is draw with colorName.it works fine . but know i have a listbox that bind to an collection(CollectionViewSource) that shows a list of element with a property name "backcolor" ,i want to selectedvalue of dropdown changed when selecteditem in listBox changed ???? my paltform is WPF and i know a few about masterDetails senario

    Read the article

  • [C#/WPF] Combo box Item source = ObservableCollection & I need a '-None-' dummy entry at the top

    - by James
    I have a combo box using an observable collection as a datasource and I want a "dummy" value of "None" as the first item in the box as it controls filters against other data sources. Other databound objects also use the same observable collection so adding a "None" value directly to the datasource is not possible as I dont want, for example, my datagrids having a "none" in them. Also I'd rather avoid filters to just remove the "none" value for those that do not use it, as I'd like the observable collection to direclty reflect the database data; if at all possible. I'd also like to avoid having one observable collection per databound control. What I'm really after is a was to put a, non data bound, first entry into a combobox while also having the item source pointed at an obervable collection. Thanks

    Read the article

  • How to Read some of the properties of the ItemSource when Laying out the Children?

    - by user275561
    Assume that I have the ItemSource bound and i am getting the data. Now what I want is this. The ItemSource will contain Data that tells where each button should be. For Example: The first Button could be at Left:200,Top:0, the Second could be Left:50 Top:20. </ItemsControl.Resources> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <Controls:MatrixCanvas /> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> <ItemsControl.ItemTemplate> <DataTemplate> <item:CustomButton Height="{Binding btnSize}" Width="{Binding btnSize}" Style="{Binding bbColor,Converter={StaticResource ButtonStyleConverter}}" /> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> protected override Size ArrangeOverride(Size finalSize) { foreach (var child in Children) { //The child } return base.ArrangeOverride(finalSize); } The Child however is not giving me access to the Item that I want. Is their a good solution for this? Am I going about this the wrong way? The reason I am doing it like this is because their can be buttons added dynamically, removed, some buttons will need to move around etc..

    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

  • 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

  • How can I bind a List as ItemSource to ListView in XAML?

    - by Jonas
    I'm learning WPF and would like to have a collection similar to a LinkedList, to where I can add and remove strings. And I want to have a ListView that listen to that collection with databinding. How can I do bind a simple list collection to a ListView in XAML? My idea (not working) is something like this: <Window x:Class="TestApp.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"> <Window.Resources> <LinkedList x:Key="myList"></LinkedList> //Wrong <Window.Resources> <Grid> <ListView Height="100" HorizontalAlignment="Left" Margin="88,134,0,0" Name="listView1" VerticalAlignment="Top" Width="120" ItemsSource="{Binding Source={StaticResource myList}}"/> //Wrong </Grid> </Window> All my code (updated version, not working): <Window x:Class="TestApp.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"> <Grid> <TextBox Height="23" HorizontalAlignment="Left" Margin="12,12,0,0" Name="textBox1" VerticalAlignment="Top" Width="120" /> <Button Content="Button" Height="23" HorizontalAlignment="Right" Margin="0,12,290,0" Name="button1" VerticalAlignment="Top" Width="75" Click="button1_Click" /> <ListView Height="100" HorizontalAlignment="Left" Margin="88,134,0,0" Name="listView1" VerticalAlignment="Top" Width="120" ItemsSource="{Binding myList}"/> </Grid> </Window> C#-code: namespace TestApp { public partial class MainWindow : Window { ObservableCollection<string> myList = new ObservableCollection<string>(); public MainWindow() { InitializeComponent(); myList.Add("first string"); } private void button1_Click(object sender, RoutedEventArgs e) { myList.Add(textBox1.Text); textBox1.Text = myList.Count+"st"; } } }

    Read the article

  • How can I bind a LinkedList as ItemSource to ListView in WPF XAML?

    - by Jonas
    I'm learning WPF and would like to have a collection similar to a LinkedList, to where I can add and remove strings. And I want to have a ListView that listen to that collection with databinding. How can I do bind a simple list collection to a ListView in XAML? My idea (not working) is something like this: <Window ...> <Window.Resources> <LinkedList x:Key="myList"></LinkedList> <Window.Resources> <Grid> <ListView Height="100" HorizontalAlignment="Left" Margin="88,134,0,0" Name="listView1" VerticalAlignment="Top" Width="120" ItemsSource="{Binding Source={StaticResource myList}}"/> </Grid> </Window>

    Read the article

  • Problem in databinding a dictionary in ListView combo-box column.

    - by Ashish Ashu
    I have a listview of which itemsource is set to my custom collection, let's say MyCollection. The code below is not full code , it's just a code snippets to explain the problem. class Item : INotifyPropertyChanged { Options _options; public Options OptionProp { get { return _options; } set { _options = value; OnPropertyChanged ("OptionProp");} } string _Name; public string NameProp { get { return _Name; } set { _Name = value; OnPropertyChanged ("NameProp");} } } class Options : Dictionary<string,string> { public Options() { this.Clear(); this.Add("One" , "1" ); this.Add("Two" , "2" ); this.Add("Three" , "3" ); } } MyCollection in my viewModel class viewModel { ObservableCollection<Item> **MyCollection**; KeyValuePair<sting,string> **SelectedOption**; } The listview Item Source is set to my MyCollection. <ListView ItemSource = MyCollectoin> I Listview contains two columns of which I have defined a datatemplats in the listview. First column is a combo-box of which Itemsource is set to Options ( defined above ) Second column is a simple textblock to display Name. Problem 1. I have defined a datatemplate for first column in which I have a combo box , I have set the Itemsource =**MyCollection** and SelectedItem = SelectedOption of the combo-box. User can perform following operations in the listview: Add ( Add the row in the listview ) Move Up ( Move row up in the listview ) Move Down ( Move down the item in the listview ) .Now when I add the row in the listview , the combo-box selected index is always comes to -1 (first column). However the combo box contains options One, Two and Three. Also, I have initialized the SelectedOption to contain the first item, i:e One. problem 2. . Let suppose, I have added a single row in a listview and I have selected Option "one" in the combo box manually. Now when I perform Move Up or Move Down operations the selected index of a combo box is again set to -1. In the Move Up or Move Down operation , I am calling MoveUp and MoveDown methods of the Observable collection. Probelm 3 How to serialize the entire collection in XML. Since I can't serialize the Dictionary and KeyValue Pair. I have to restore the state of the listview.

    Read the article

  • WPF: Binding Combobox in Code Behind to Property

    - by Richard
    Hi All, This might be something very straight forward and I really think it should work as is, but it doesn't... I have the following scenario: var itemSource = new Binding { Path = new PropertyPath("ItemList"), Mode = BindingMode.OneTime }; comboBox.SetBinding(ItemsControl.ItemsSourceProperty, itemSource); ItemList is simply: public IList<string> ItemList { get { return Enum.GetNames(typeof(OptionsEnum)).ToList(); } } I would have expected this to bind the list of items to the Combobox, and when I do it in XAML it works fine, but I have to do it in code behind... Any ideas?

    Read the article

  • WPF Hide DataGridColumn via a binding

    - by Greg R
    For some reason I can't hide WPF Toolkit's DataGridColumn. I am trying to do the following: <dg:DataGridTemplateColumn Header="Item Description" Visibility="{Binding IsReadOnly}"> <dg:DataGridTemplateColumn.CellTemplate> <DataTemplate> <TextBox Text="{Binding Path=ItemDescription}" /> </DataTemplate> </dg:DataGridTemplateColumn.CellTemplate> This doesn't work, since it's looking for a IsReadOnly property on the ItemSource (not a property of the current class). If add this as a property of the ItemSource class that implements INoifyPropertyChanged, it still doesn't hide the column. Is there a way around this? I want the column to hid when a button click changes IsReadOnly property. Assume IsReadOnly returns a Visibility value and is a dependency property I am completely stuck, I would really appreciate the help! Thanks a lot!

    Read the article

  • Setting CommandTarget to selected control in a TabControl

    - by Bart
    I have a WPF window with a few buttons and a tabcontrol having a tab for each 'document' the user is working on. The tabcontrol uses a DataTemplate to render the data in ItemSource of the tabcontrol. The question: If one of the buttons is clicked, the command should be executed on the control rendering the document in the active tab, but I've no idea what I should set CommandTarget to. I tried {Binding ElementName=nameOfControlInDataTemplate} but that obviously doesn't work. I tried to make my problem a bit more abstract with the following code (no ItemSource and Document objects, but the idea is still the same). <Button Command="ApplicationCommands.Save" CommandTarget="{Binding ElementName=nestedControl}">Save</Button> <TabControl x:Name="tabControl"> <TabControl.Items> <TabItem Header="Header1">Item 1</TabItem> <TabItem Header="Header2">Item 2</TabItem> <TabItem Header="Header3">Item 3</TabItem> </TabControl.Items> <TabControl.ContentTemplate> <DataTemplate> <CommandTest:NestedControl Name="nestedControl"/> </DataTemplate> </TabControl.ContentTemplate> </TabControl> I tested the code by replacing the complete tabcontrol with only one single NestedControl, and then the command button just works. To be complete, here is the code of NestedControl: <UserControl x:Class="CommandTest.NestedControl" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <Grid> <Label x:Name="label" Content="Not saved"/> </Grid> </UserControl> And code behind: public partial class NestedControl : UserControl { public NestedControl() { CommandBindings.Add(new CommandBinding(ApplicationCommands.Save, CommandBinding_Executed)); InitializeComponent(); } private void CommandBinding_Executed(object sender, ExecutedRoutedEventArgs e) { label.Content = "Saved"; } }

    Read the article

  • How do I programmatically insert rows into a Silverlight DataGrid without binding?

    - by j0rd4n
    I am using a common Silverlight DataGrid to display results from a search. The "schema" of the search can vary from query to query. To accommodate this, I am trying to dynamically populate the DataGrid. I can set explicitly set the columns, but I am having trouble setting the ItemSource. All of the MSDN examples set the ItemSource to a collection with a strong type (e.g. a Custom type with public properties matching the schema). The DataGrid then uses reflection to scour the strong type for public properties that will match the columns. Since my search results are dynamic, I cannot create a strong type to represent what comes back. Can I not just give the DataGrid an arbitrary list of objects so long as the number of objects in each list matches the number of columns? Anyone know if this is possible? I would like to do something similar to this: List<List<object>> myResults = <voodoo that populates the result list> myDataGrid.ItemsSource = myResults;

    Read the article

  • Having ObservableCollection Trigger an update

    - by user275561
    So i have something along the lines of private ObservableCollection<ViewModel> _internal; public ObservableCollection<ViewModel> BoundInternal{get;set}; //this is Binded in the Itemssource like ItemSource={Binding BoundInternal} Now In my code i do something like BoundInternal=_internal, However the problem is the BoundInternal isn't trigger any collectionChanged event. I have to use the Add method. So I am wondering if there is a solution to this.

    Read the article

  • WPF DataGrid cannot Add a row when datasource is empty

    - by Trindaz
    CanUserAddRows="True" only 'works' when there's already data in the itemsource of the data grid. If it just so happens that there are no rows in the original list of items, then the datagrid doesn't display a 'placeholder' row for entering new items, even though I've set CanUserAddRows="True". Why?! Thanks in advance, Trindaz

    Read the article

  • How to bind an List<List<String>> to the gridview ?

    - by user301089
    Hi everyone, I'm using the new Telerik Rad Control and I would to use the GridView included. But my problem is I recover with a webservice a List<List<String>> object and I would like to show it into my Datagridview. I try to make a Grid.ItemSource = e.result but nothing appears ;-( What's the problem ? Thanks a lot. Narglix

    Read the article

  • How to edit boolean in a DataGridCheckBoxColumn in Silverlight 3

    - by Polo
    Hello, I have a datagrid with some TextColumn and one DataGridCheckBoxColumn. I bind it with à itemsource that contaned à boolean and i can see that my checkboxes or checked or not by the boolean everything is OK at this point. but the checkboxs cells are in ReadOnly even if i assigne IsReadOnly = False. I cant find the right and clean way to enable the editing. I dont need data validation but juste to be able to edit and check those checkboxes :) If anyone can help! thanks !!

    Read the article

  • How to eager load in WCF Ria Services/Linq2SQLDomainModel

    - by Aggelos Mpimpoudis
    I have a databound grid at my view (XAML) and the Itemsource points to a ReportsCollection. The Reports entity has three primitives and some complex types. These three are shown as expected at datagrid. Additionally the Reports entity has a property of type Store. When loading Reports via GetReports domain method, I quickly figure out that only primitives are returned and not the whole graph of some depth. So, as I wanted to load the Store property too, I made this alteration at my domain service: public IQueryable<Report> GetReports() { return this.ObjectContext.Reports.Include("Store"); } From what I see at the immediate window, store is loaded as expected, but when returned to client is still pruned. How can this be fixed? Thank you!

    Read the article

  • Styling hyperlink button inside a data template in Silverlight

    - by cmaduro
    How do I change the visual state of a hyperlinkbutton inside a datatemplate? In short, what I'm doing is basically I'm trying to iterate of the hyperlinkbuttons and set their visual state to active or inactive according to the url. The hyperlink buttons are located inside the datatemplate of an itemscontrols itemsource that is bound to a List where link is my custom class for links. Is there a best practice for styling the active hyperlink in a silverlight nav app? What I am using is the approach of the boilerplate code.

    Read the article

  • WPF ComboBox Object Binding - not updating DataContext Object

    - by Jaysen
    Hello, I have the following scenario: 1 class called 'Widget' with the properties: ID, Code, Description 1 class called 'MyWidget' with a property: m_Widget As Widget 1 ComboBox The ComboBox has a List(Of Widget) set as the ItemSource. I create an instance of 'MyWidget' named MyWidget1 and I set the property values of the m_Widget to match one of the items in the 'ComboBox List(Of Widget)'. I then set the DataContext of the ComboBox to MyWidget1.Widget. When I change the ComboBox selected item, only the ID property of 'MyWidget1.Widget' gets updated... How do I get the object 'Widget' on 'MyWidget1' to be updated instead of just 'MyWidget1.Widget.ID'? Here is a link to a sample project demonstrating this scenario: http://www.webpersona.com/ObjectBinding.zip Thanks in advance for any help :)

    Read the article

  • Binding list of objects to WPF ListView

    - by Dave Colwell
    Hi all, I have a list of objects which i want to bind to a ListView control in my WPF application. The Objects have a DataTemplate already, so no need to define that. The list of objects is a property in the codebehind file in the format list<object> When i add one object programatically, it appears fine. But when i try to bind the ItemSource of the ListBox to the list of objects, nothing shows up. I am using the following binding: ItemsSource="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=Portfolios}" where the name of the property i am trying to bind to is Portfolios and exists on the parent window

    Read the article

  • Button click event

    - by Malcolm
    I am binding an object of other class to a silverlight list box itemsource.I want to fire the click event of a button,but I don't want to define command under this class. I have defined other class and have defined command inside it. Now the question is how to bind the command of this class to the command property of that button. There are two classes A and B I am binding the item source of a listbox to A and i have defined a command in B and i need this command to bind with the button present inside the listbox.(ie..listbox-listboxitem-button) Is there any way to bind to a property outside of the current data context?

    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

  • Silverlight - rebinding to a property?

    - by bplus
    Hello, I'm just getting started with silverlight. Basically I have a silverlight user control that has various dataGrids and a combobox, their item sources set to the properties of a custom plain c# object. My problem is that I have a dropdown list that when a user selects an item from the list a new row should appear in one of the grids. All I'm doing is handling the SelectionChanged event and adding a new item to to a list in my custom object and setting the itemsource for the grid again. This doesnt seem to work; no row is added to the dataGrid I have no idea how to force my grid to "rebind" to this property. I've been reading about dependency properties, are these what I need? Any pointers would be really appreciated.

    Read the article

  • Trapping events within list box item templates in WPF

    - by AC
    I've got listbox that employs an item template. Within each item in the list, as defined in the template there is a button. When the user clicks the button I change a value in the data source that defines the sort order of the list. Changing the datasource is not a problem as this is working just fine within my application template. However my next step is to reload the listbox with the new sorted data source. I've tried doing this from the tempalte but it apparently doesn't have access (or I can't figure out how to get access) to the parent elements so I can reset the .ItemSource property with a newly sorted data source. Seems like this is possible but the solution is eluding me :(

    Read the article

1 2 3  | Next Page >