I'm trying to drag an item from a listbox to a textbox in WPF.
I can't get any code that will let me do this.
Thanks
Use selection change event of listbox
private void listBox2_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
ListBoxItem i = (ListBoxItem)listBox2.Items[listBox2.SelectedIndex];
s = i.Content.ToString();
DragDrop.DoDragDrop(listBox2, i.Content.ToString(), DragDropEffects.All);
}
Related
I want to insert autocomplete textboxes inside listview control in WPF.
well I downloaded a premade auto complete textbox from nugget called "WpfControls.AutoCompleteTextBox"
here's the code to add it:
private void button_Click_1(object sender, RoutedEventArgs e)
{
WpfControls.AutoCompleteTextBox TestTextBox = new WpfControls.AutoCompleteTextBox();
listView.Items.Add(TestTextBox);
}
How can we know if a row is dirty in a telerik gridview?
In datagridview we had IsCurrentRowDirty property.
Is there any such property in Telerik?
One way to do this with RadGridView is to use the CellValueChanged event:
void radGridView1_CellValueChanged(object sender, GridViewCellEventArgs e)
{
e.Row.Tag = "ThisRowIsDirty";
}
I have multiple dynamic generated Expanders having DataGrid as Content, and CheckBoxes in DataGrid. I got the DataGrid with the following code below but don't know how to get the Expander.
private void ChkBoxDamage_Checked(object sender, RoutedEventArgs e)
{
CheckBox b = (CheckBox)e.Source;
DataGridRow row = b.TemplatedParent.TryFindParent<DataGridRow>();
row.Background = System.Windows.Media.Brushes.Red;
DataGrid dataGrid = b.TemplatedParent.TryFindParent<DataGrid>();
Expander Gridexpanderr = dataGrid.TemplatedParent.TryFindParent<Expander>();
Gridexpanderr.Background = new SolidColorBrush(Colors.Red);
}
The above code won't change expander Background Color.
i have 7 songs in list box control.if i selected those songs from listbox that songs should be play in media element?
please help me..
thanks in advance.
You can use the Listbox SelectionChanged event for changing theMediaElement source property like
private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
MediaElement1.Source = new Uri(FilePath);
}
You will get more informatin about this in MediaElement in wpf
I am using a checkbox on expander. I want, when I check that checkbox ,it will select all rows of list view those are coming under that expander.
set the listview's selectionmode to Multiple' or 'Extended and
on the CheckBox_Checked event you can write the code to select the rows of listview
private void CheckBox_Checked(object sender, RoutedEventArgs e)
{
listview1.SelectAll();
}
Try this inside your checkbox_click events handler:
listView1.BeginUpdate();
foreach (ListViewItem i in listView1.Items)
{
i.Selected = true;
}
listView1.EndUpdate();
Which gives you a bit more flexibility.