I have a listview in WPF that doesn't add the second row until a third row is added and then all three render. Each next row renders correctly and immediately.
I don't really have a clue on why this happens only on the second time.
wpf code:
<ListView Name="DownloadList" Background="WhiteSmoke" PreviewMouseRightButtonUp="DownloadList_PreviewMouseRightButtonUp" >
<ListView.View>
<GridView>
<GridViewColumn Width="140" Header="Name" DisplayMemberBinding="{Binding Name}"/>
<GridViewColumn Width="80" Header="Status" DisplayMemberBinding="{Binding Status}"/>
<GridViewColumn Width="60" Header="Size" DisplayMemberBinding="{Binding FormattedSize}"/>
<GridViewColumn Width="70" Header="Speed" DisplayMemberBinding="{Binding FormattedSpeed}"/>
<GridViewColumn Width="170" Header="Progress">
<GridViewColumn.CellTemplate>
<DataTemplate>
<ProgressBar Height="20" Width="150" Maximum="{Binding Size}" Value="{Binding Progress}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Width="65" Header="Time Left" DisplayMemberBinding="{Binding FormattedTime}"/>
<GridViewColumn Width="60" Header="Peers" DisplayMemberBinding="{Binding Peers}"/>
</GridView>
</ListView.View>
</ListView>
behind code:
FileDownload download = new FileDownload(fileToDownload.id, fileToDownload.DownloadName,(int)fileToDownload.Length, partsData.Length);
wpfDownloads.Add(download);
Related
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:AraWPF"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
<ListView x:Name="listView">
<ListView.View>
<GridView>
<GridViewColumn Header="call" DisplayMemberBinding="{Binding Call}" Width="100" />
<GridViewColumn Header="name" DisplayMemberBinding="{Binding Name}" Width="200" />
<GridViewColumn Header="path" DisplayMemberBinding="{Binding Path}" Width="100" />
<GridViewColumn Header="link" DisplayMemberBinding="{Binding Link}" Width="100" />
<GridViewColumn Header="description" DisplayMemberBinding="{Binding Description}" Width="100" />
</GridView>
</ListView.View>
</ListView>
</Grid>
</UserControl>
it's my GridView to print my data
I want to add button to GridView.
Is there any way to add button to View which is table
I'm sorry for my bad english skill.
You can use templates:
<GridView>
<GridViewColumn Header="call" DisplayMemberBinding="{Binding Call}" Width="100" />
<GridViewColumn Header="name" DisplayMemberBinding="{Binding Name}" Width="200" />
<GridViewColumn Header="path" DisplayMemberBinding="{Binding Path}" Width="100" />
<GridViewColumn Header="link" DisplayMemberBinding="{Binding Link}" Width="100" />
<GridViewColumn Header="description" DisplayMemberBinding="{Binding Description}" Width="100" />
<GridViewColumn Header="Button" Width="100">
<GridViewColumn.CellTemplate>
<DataTemplate>
<!-- Your button using bindings, ... -->
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
I have A listView In which i want to show items from dataBase. It works fine, But i want to see the items shown in cells as white in a purple listview, How to do it ?
<ListView Margin="127,114,227,357" x:Name="lv" Background="purple" >
<ListView.View>
<GridView>
<GridViewColumn DisplayMemberBinding="{Binding Path=FirstName}" Header="First Name" Width="100" />
<GridViewColumn DisplayMemberBinding="{Binding Path=LastName}" Header="Last Name" Width="100" />
<GridViewColumn DisplayMemberBinding="{Binding Path=Email}" Header="Email" Width="100" />
<GridViewColumn DisplayMemberBinding="{Binding Path=Password}" Header=" Password" Width="100" />
<GridViewColumn DisplayMemberBinding="{Binding Path=Address}" Header="Address" Width="100" />
</GridView>
</ListView.View>
You need to use DataTemplate and change the text Foreground property, this is one sample for GridViewColumn.
Check on DataTemplate here: Data Templating Overview
<GridViewColumn DisplayMemberBinding="{Binding Path=FirstName}" Header="First Name" Width="1000">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock x:Name="Txt" Text="{Binding FirstName}" Foreground="Purple" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
As per the accepted answer, in order for the TextBlock to remain binded and the Foreground color to change, the following worked for me:
<GridViewColumn Header="First Name" Width="1000">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock x:Name="Txt" Text="{Binding Path=FirstName}" Foreground="Purple" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
and in my case I decided to create a property for the text color and bind to that
<GridViewColumn Header="First Name" Width="1000">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock x:Name="Txt" Text="{Binding Path=FirstName}" Foreground="{Binding Path=TextColor}" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
All wrong answers. You simply need to change GridView.ColumnHeaderTemplate property.
<ListView ItemsSource="{...}" Foreground="White" >
<ListView.View>
<GridView>
<GridView.ColumnHeaderTemplate>
<DataTemplate>
<TextBlock Foreground="White" Text="{Binding}"/>
</DataTemplate>
</GridView.ColumnHeaderTemplate>
<GridViewColumn DisplayMemberBinding="{Binding Path=FirstName}" Header="First Name" Width="1000"/>
I have to monitor all the frames on a network. For this, I've created 2 ListViews, one for showing the frame names, dlcs, payloads and timestamp. I have an event which fires when a new frame is received and an update is made in the frames ListView.
If i select one frame in the lv, the second ListView is populated with small information about the selected frame. Both, the selected line, and the whole second ListView are updating as that event fires and the frame payload changes.
I have only one Dispatcher.Invoke for all this work, and it seems that the GUI stays behind with the updates. Should I use two dispatchers?
One for the frame updates in the first ListView and the second for the other ListView? What priorities should I select for each of them? At this moment i am using the 6th level, named: Loaded.
<ListView ItemsSource="{StaticResource frames}"
Grid.Row="0"
Margin="0,1,0,1"
Name="lvFrames"
VerticalContentAlignment="Top"
ItemContainerStyleSelector="{StaticResource itemSelector}"
FontSize="12"
VirtualizingStackPanel.VirtualizationMode="Recycling"
VirtualizingStackPanel.IsVirtualizing="True"
BorderThickness="1"
BorderBrush="Gray"
Grid.ColumnSpan="2"
SelectionChanged="lvFrames_SelectionChanged">
<ListView.View>
<GridView>
<GridViewColumn Header="Time" DisplayMemberBinding="{Binding Time}" Width="55"/>
<GridViewColumn Header="Dir" DisplayMemberBinding="{Binding Dir}" Width="40"/>
<GridViewColumn Header="Id" DisplayMemberBinding="{Binding Id}" Width="40"/>
<GridViewColumn Header="Name" DisplayMemberBinding="{Binding Name}" Width="125"/>
<GridViewColumn Header="Dlc" DisplayMemberBinding="{Binding Dlc}" Width="40" />
<GridViewColumn Header="Data" DisplayMemberBinding="{Binding Data}" Width="150" />
</GridView>
</ListView.View>
</ListView>
This is the XAML for the first ListView:
<ListView ItemsSource="{StaticResource signals}"
Grid.Row="0"
Margin="0,1,-0.48,0"
Name="lvSignals"
VerticalContentAlignment="Bottom"
FontSize="12" VirtualizingStackPanel.VirtualizationMode="Recycling"
VirtualizingStackPanel.IsVirtualizing="True"
BorderThickness="1" BorderBrush="Gray" Grid.ColumnSpan="2"
VerticalAlignment="Stretch">
<ListView.View>
<GridView>
<GridViewColumn Header="Signal Name"
DisplayMemberBinding="{Binding Name}" Width="160" />
<GridViewColumn Header="Signal Value"
DisplayMemberBinding="{Binding Value}" Width="100"/>
</GridView>
</ListView.View>
</ListView>
And this one for the signals ListView.
I have some ListView and I want that they all have the same View. So, if the following is my View:
<ListView.View>
<GridView>
<GridViewColumn Width="140" Header="Game Name"
DisplayMemberBinding="{Binding GameName}" />
<GridViewColumn Width="140" Header="Creator"
DisplayMemberBinding="{Binding Creator}" />
<GridViewColumn Width="140" Header="Publisher"
DisplayMemberBinding="{Binding Publisher}" />
</GridView>
</ListView.View>
I want something like this:
<Grid>
<ListView>
<!--Here my ListView is the same defined above-->
</ListView>
<ListView>
<!--Here my ListView is the same defined above-->
</ListView>
</Grid>
How can I accomplish this?
Define view in resources (either in resource dictionary of top-level control, or in external resource dictionary):
<StackPanel>
<StackPanel.Resources>
<GridView x:Key="myView" x:Shared="false">
<GridViewColumn Width="140" Header="Game Name"
DisplayMemberBinding="{Binding GameName}" />
<GridViewColumn Width="140" Header="Creator"
DisplayMemberBinding="{Binding Creator}" />
<GridViewColumn Width="140" Header="Publisher"
DisplayMemberBinding="{Binding Publisher}" />
</GridView>
</StackPanel.Resources>
<ListView View="{StaticResource myView}"/>
<ListView View="{StaticResource myView}"/>
</StackPanel>
Use this. Cheers
<Grid>
<ListView Name="FirstList">
<ListView.View>
<GridView>
<GridViewColumn Width="140" Header="Game Name" DisplayMemberBinding="{Binding GameName}" />
<GridViewColumn Width="140" Header="Creator" DisplayMemberBinding="{Binding Creator}" />
<GridViewColumn Width="140" Header="Publisher" DisplayMemberBinding="{Binding Publisher}" />
</GridView>
</ListView.View>
</ListView>
<ListView View="{Binding Path=View, ElementName=FirstList}" />
</Grid>
How do I bind DisplayMemberBinding when my ItemsSource is a List<string[]> in my GridView?
EDIT:
Figured it out! No need to answer. (binded to [i], where i is array index)
You can use-
<ListView ItemsSource="{Binding ListOfStringArrays}">
<ListView.View>
<GridView>
<GridViewColumn Width="140" DisplayMemberBinding="{Binding [0]}" />
<GridViewColumn Width="140" DisplayMemberBinding="{Binding [1]}"/>
<GridViewColumn Width="140" Header="Column 3" DisplayMemberBinding="{Binding [2]}"/>
</GridView>
</ListView.View>
</ListView>