listviewitem

Cast ListView Items to List<string>?

人盡茶涼 提交于 2019-12-03 10:38:21
How can I cast ListView.Items to a List<string> ? This is what I tried: List<string> list = lvFiles.Items.Cast<string>().ToList(); but I received this error: Unable to cast object of type 'System.Windows.Forms.ListViewItem' to type 'System.String'. A ListViewItemCollection is exactly what it sounds like - a collection of ListViewItem elements. It's not a collection of strings. Your code fails at execution time for the same reason that this code would fail at compile time: ListViewItem item = lvFiles.Items[0]; string text = (string) item; // Invalid cast! If you want a list of strings, each of

Determining which ListViewItem was clicked on in a ListView when executing a ContextMenu MenuItem

余生长醉 提交于 2019-12-03 09:31:45
I'm trying to use the context menu in a listview to run some code that requires data from which item it originated from. I initially just did this: XAML: <ListView x:Name="lvResources" ScrollViewer.VerticalScrollBarVisibility="Visible"> <ListView.Resources> <ContextMenu x:Key="resourceContextMenu"> <MenuItem Header="Get Metadata" Name="cmMetadata" Click="cmMetadata_Click" /> </ContextMenu> </ListView.Resources> <ListView.ItemContainerStyle> <Style TargetType="{x:Type ListViewItem}"> <Setter Property="ContextMenu" Value="{StaticResource resourceContextMenu}" /> </Style> </ListView

How to highlight ListView-Items

大兔子大兔子 提交于 2019-12-03 05:44:43
i got the following problem. i have a ListView with custom rows consisting of an imageview and a textview. the textview's xml code is <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/label" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="26px" android:layout_marginLeft="3px" android:singleLine="true" android:ellipsize="end" android:textColorHighlight="#FEC403" /> then i have an itemclicklistener that works fine and i want to highlight the textview that has been clicked by doing the following. public void

WPF MVVM: Listview checkbox header for selecting/unselecting all the listview items

一个人想着一个人 提交于 2019-12-02 20:21:12
问题 I am trying to select/unselect all the listview items when checkbox in listview header is clicked. View (xaml) : <ListView Margin="10" Name="MyLv" ItemsSource="Binding Path=lstData}" SelectionMode="Extended"> <ListView.ItemContainerStyle> <Style TargetType="ListViewItem"> <Setter Property="IsSelected" Value="{Binding IsSelected}"/> </Style> </ListView.ItemContainerStyle> <ListView.View> <GridView> <!-- Checkbox column --> <GridViewColumn> <GridViewColumn.Header> <CheckBox x:Name="CheckAll"

How to handle ItemClick For Nested ListView In MVVM Pattern?

时光毁灭记忆、已成空白 提交于 2019-12-02 11:00:27
Xaml code: <Page x:Class="DemoTestApp.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:DemoTestApp" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" xmlns:vm="using:ViewModels" > <Page.DataContext> <vm:TestViewModel/> </Page.DataContext> <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <ListView Name=

Listview selection color

孤者浪人 提交于 2019-12-02 05:04:54
问题 I'm playing around with wpf and I saw the following article: WPF ListView Inactive Selection Color I want to do something similar. I want to put a border around an a listviewitem when it is selected and i want to not change the background color. The reason I want this is I want a color coded listview and I still want to see the color when it's selected, but i want to know it's selected by it having a border around it. Any ideas? UPDATE: I tried the below answer and it got me half way, it does

Get the notification code from Listview Control checkboxes

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-01 21:12:36
问题 I've implemented a ListView control with LVS_EX_CHECKBOXES | LVS_EX_INFOTIP style. I've registered function to get notified from list view control items using. BEGIN_MESSAGE_MAP(Class, ParentClass) ON_NOTIFY(LVN_GETINFOTIP,IDC_LIST2,OnClickCheckBox) END_MESSAGE_MAP() My question is, what notification code will be sent to parent when you select/de-select the checkbox in the item of ListView control.. What code need to be written to handle checkbox selection in the OnClickCheckBox() function ?

WPF ListView Highlight Color don't change

邮差的信 提交于 2019-12-01 12:49:21
I have a ListView with three TextBlock for each Item. The first one has the default color (black) and the others has the property Foreground set to gray. When I select an item the color of the first TextBlock becomes blue but the others stay gray and are hard to read. I want that all the text become white color when the item is selected. How I do that ? Edit : My style : <UserControl.Resources> <Style TargetType="{x:Type ListViewItem}"> <Style.Triggers> <Trigger Property="IsSelected" Value="True"> <Setter Property="Foreground" Value="White"/> </Trigger> </Style.Triggers> </Style> </UserControl

Load data into an ExpandableListView

隐身守侯 提交于 2019-12-01 12:27:31
I am searching for a way to load data into an Expandale List View, the output I want to resemble the one of the picture attached here In order this to be done dynamically, is it better to be read from a csv? Or to create a DB? Furthermore, on a sub-item press, I want a ScrollView to appear. Here is the code so far: The layout of the activity: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="wrap_content"> <ExpandableListView android:id= "@+id

Load data into an ExpandableListView

谁都会走 提交于 2019-12-01 10:35:18
问题 I am searching for a way to load data into an Expandale List View, the output I want to resemble the one of the picture attached here In order this to be done dynamically, is it better to be read from a csv? Or to create a DB? Furthermore, on a sub-item press, I want a ScrollView to appear. Here is the code so far: The layout of the activity: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android