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>
Related
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);
How to style every cell in Gridview.I want my cell text in a rounded text box with red background.My code is
<ListView Margin="0" ItemsSource="{Binding ParamList}" >
<ListView.View >
<GridView >
<GridView.ColumnHeaderTemplate>
<DataTemplate>
<Border BorderThickness="2" CornerRadius="5" Height="75" MinWidth="60" >
<Border.Background>Gray</Border.Background>
<TextBlock Foreground="WhiteSmoke" Margin="5"
Text="{Binding}" Width="Auto"
HorizontalAlignment="Center" VerticalAlignment="Center" />
</Border>
</DataTemplate>
</GridView.ColumnHeaderTemplate>
<GridViewColumn Header="category1" DisplayMemberBinding="{Binding Path=param1}" />
<GridViewColumn Header="category2" DisplayMemberBinding="{Binding Path=param1}" />
</GridView>
</ListView.View>
</ListView>
Use the GridViewColumn's CellTemplate property to set a DataTemplate containing a TextBox with the appropriate styling for each of your columns. I don't believe there is a way to set it at the Gridview level so that you don't have to set it on each column individually.
<Grid>
<ListView ItemsSource="{Binding Items}">
<ListView.View>
<GridView>
<GridView.Columns>
<GridViewColumn>
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Background="Red" Text="{Binding Item1}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn>
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Item2}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView.Columns>
</GridView>
</ListView.View>
</ListView>
</Grid>
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>
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).