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.
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 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);
I am trying to display StandardEventLevel as text, but I don't understand how to do so.
My XAML-code (Level is StandardEventLevel Enumeration):
<ListView x:Name="eventsView"
Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2"
MouseDoubleClick="eventsView_MouseDoubleClick" >
<ListView.View>
<GridView>
<GridViewColumn Width="Auto"
Header="Level"
DisplayMemberBinding="{Binding Level}"/>
</GridView>
</ListView.View>
</ListView>
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'm trying to get a textbox to be shown in a column of listview that also uses GridView.
<ListView Margin="30,120,0,0" Name="EquipmentView" SelectionChanged="EquipmentView_SelectionChanged" ItemsSource="{Binding}" Foreground="Black" FontWeight="Normal" FontFamily="Segui Bold" HorizontalAlignment="Left" Width="329" Height="100" VerticalAlignment="Top">
<ListView.View>
<GridView>
<GridViewColumn Header="Control" Width="175" DisplayMemberBinding="{Binding Path=Control}">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=ControlBlock}" Width="Auto" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="Setting" Width ="150" DisplayMemberBinding="{Binding Path=Setting}">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBox Text="{Binding Path=SettingText}" Width="Auto" GotFocus="TextBox_GotFocus" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
But when I execute the above, I sit the listview as a grid, but I can't see or edit the textbox. Any help will be greatly appreciated. Thanks in advance.
Remove the DisplayMemberBinding since you've specified a template for that column (both columns, actually).