I have a combobox in a gridview in my silverlight application.
<Controls1:GridViewComboBoxColumn Header="Accomplishment Category"
ItemsSource="{Binding AccomplishmentCategoryList}"
DataMemberBinding="{Binding AccomplishmentCategoryValue}"
SelectedValueMemberPath="{Binding AccomplishmentCategoryValue}">
</Controls1:GridViewComboBoxColumn>
I am able to get my grid to display the results for its own itemSource.
<Controls1:RadGridView x:Name="Accomplishments" Grid.Row="1" CanUserInsertRows="True"
ShowInsertRow="True" CanUserDeleteRows="True" RowIndicatorVisibility="Visible"
IsReadOnly="False" ItemsSource="{Binding AccomplishmentResults, Mode=TwoWay}">
The AccomplishmentResults collection binds perfectly. my issue is the combobox does not display anything until you actually click on the column that contains the combobox control. so that column looks empty, when you click on the column the results are displayed, when you click again you get the combobox that will show the items in that collection..if you select anything other than that column those values disappear and are empty again. if you select the row they remain empty..it is only when the column is selected that the values appear.
By default ListView and DataGrid only displays text till the item is clicked and item becomes editable.
You will have to create Templated Column, that will always display combobox as declared in template.
Related
I have a ComboBox which takes it's values from ObservableCollection which gets it's data from a XML file.
I am able to display the data from XML to the ComboBox whose code is :
<ComboBox x:Name="ComboBox1" ItemSource="{Binding Path = <Property Name>}" DisplayMemberPath="Name" SelectedItem="{Binding SelectedItem, UpdateSourceTrigger=PropertyChanged}">
Now I want to make modifications such that only some Items in the ComboBox have a checkbox which will be based on the text of the ComboBox Item.
If I use Data Template in ComboBox.ItemTemplate, then all the items of combobox will have the checkbox which I don't want.
Is there any way I can achieve this?
In the ItemTemplate, use the DataTemplate in which there will be triggers that change the Visibility of the flag according to the conditions you need.
I have a view that opens up on a button click. The view has a combo box that the user is requesting that when the view opens, the combo box is already selected so they don't have to click on it. Is there anyway to achieve this?
Are you saying that you would like to have an initial value selected in the ComboBox when you load the view? If you defined your ComboBox with static content, meaning the ComboBox's ItemSource property isn't bound to an object that was constructed using the results of a database query, you could set the IsSelected property of the ComboBoxItem you want selected to true. For example:
If I want to have the apples initially selected in the example below, I could do the following:
<ComboBox Name="fruits" >
<ComboBoxItem Content="apples" IsSelected="true"/>
<ComboBoxItem Content="pears"/>
<ComboBoxItem Content="oranges"/>
</ComboBox>
I have a table in my database that represents a list of areas. I would like to get all of these items in this list and bind them to a combobox dropdown in my datagrid. This currently works, and my grid column displays this dropdown. However, when I select an item in the cell and move to the next row, the cell becomes blank. Also, if the entry in the database has a saved value of "area1", and my dropdown list has "area1,area2,area3,etc", when the grid loads, it doesn't autoselect area1, the cell is simply blank.
In my model:
comboboxColumn1.ItemsSource = ctx.AREAS;//db context loading all areas into combobox
In my xaml:
<DataGrid.Columns>
<DataGridComboBoxColumn DisplayMemberPath="Name" Header="some header" x:Name="comboboxColumn1" SelectedValueBinding="{Binding Name}" />
....
How would I go about setting this selected value so that it is equal to whatever entry is in the db?
You need to set the SelectedValuePath value to your variable property. The DisplayMemberPath is for what is shown, and SelectedValuePath is what is selected. SelectedItem is the actual item that is selected.
I have a WPF DataDrid where I'm using a combination of row selection and cell selection.
That is - I want full row select and an indication of the currently selected simultaneously. That is working fine if I use SelectionUnit=FullRow and SelectionMode=Single and combined with a thicker cell border this looks pretty good.
The problem is that when the DataGrid loses focus only the row selection stays visible, the CurrentCell property is reset and there is no way for the user to identify which cell is selected. This also happens if the user is interacting with the content in the RowDetails panel.
Is there any way to change the behavior of the current cell so that it shows the SelectedCell even when not focused?
Do not use the CurrentCell to track the selected row. Use the property SelectedItem instead.
Something like this:
<DataGrid ItemsSource="{Binding MyItems}" SelectedItem="{Binding MySelectedItem}">
...
</DataGrid>
I have a Listbox that is filled with 30,000 elements
<ListBox Name="lbWordlist"
Grid.Row="1" Margin="10"
ItemsSource="{Binding Source={StaticResource WordListViewSource}}"
SelectedItem="{Binding Source={StaticResource MainViewModel}, Path=SelectedArticle}"
IsSynchronizedWithCurrentItem="True"
SelectionChanged="lbWordlist_SelectionChanged" />
I'm tracking history of user clicking items
I have 2 buttons Prev. and Next, these buttons allow user to go back and forward in history.
Prev. and Next button modify SelectedItem property of ListBox
The problem comes up, if user selects random items from ListBox that are very apart from each other (for example user selected some items on top of the list and few items in the bottom of the list).
Prev. and Next button change SelectedItem property, but ListBox is not synced with scroll, selected item is not highlighted and most of the times is not visible to user, as it's outside of ListBox's visible items area.
Is there any way to make ListBox correctly show currently selected item?
Thank You.
_listBox.ScrollIntoView(_listBox.SelectedItem);