listbox

Displaying Content only when ListViewItem is Selected

雨燕双飞 提交于 2019-12-06 11:57:35
问题 I have a ListBox when one of the ListBoxItems are selected I want to change the visibility of the button "View" and display it. Meaning that the default state is Hidden. Is this possible and if so, do I solve this with a trigger in XAML or in code behind? XAML Piece <ListBox Background="Transparent" ItemContainerStyle="{StaticResource listBoxTemplate}" BorderThickness="0"> <ListBox.ItemsPanel> <ItemsPanelTemplate> <StackPanel Orientation="Vertical" VerticalAlignment="Center" /> <

DataTextField in a ListBox is a combination of 2 fields

狂风中的少年 提交于 2019-12-06 10:44:05
I have a listbox containing Users. The datasource is an generic list of the type User (contains, id, firstname, lastname, ...). Now I want to use the id as datavalue (through dataValueField) and I want LastName + ' ' + Firstname as a DataTextField. Can anyone tell me how this is possible? I'm using C# (ASP.NET). The easiest way is to add a new property to the User class that contains the full name: public string FullName { get { return LastName + " " + FirstName; } } And bind the listbox to that. This has the advantage of centralising the logic behind how the full name is constructed, so you

Wpf how to print ListBox

倾然丶 夕夏残阳落幕 提交于 2019-12-06 10:32:27
I would like to know what is the easiest way to print ListBox's values. I have tried to use FlowDocumentReader but with no success. If you are trying to print a visual element,you can use PrintDialog printDlg = new PrintDialog(); printDlg.PrintVisual(ListBox1, "Listbox Printing."); It can be used to print any visual object(any control, container, Window or user control) If you are looking to print the items only then you can use the FlowDocument FlowDocument fd = new FlowDocument(); foreach (object item in items) { fd.Blocks.Add(new Paragraph(new Run(item.ToString()))); } fd.Print(); or

How to access ListBox dynamically-created-items' properties from code-behind?

点点圈 提交于 2019-12-06 10:09:38
XAML: <Window x:Class="WpfApp_ListBoxTest.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="300" Width="300"> <Grid> <ListBox Name="lb" Margin="0,0,0,70"></ListBox> <Button Height="23" HorizontalAlignment="Left" Margin="12,0,0,41" Name="btnAdd" VerticalAlignment="Bottom" Content="Add item" Width="75" Click="btnAdd_Click"></Button> <TextBox Height="23" Margin="93,0,12,41" Name="txtInput" VerticalAlignment="Bottom" /> <Button Height="23" HorizontalAlignment="Left" Margin="12,0,0,12" Name=

How to highlight selected item in list box windows phone?

ぐ巨炮叔叔 提交于 2019-12-06 09:58:48
问题 I am developing a windows phone application. I placed list box control in my app and displayed a list. I need to highlight the selected row with a blue color. How can I do that ?. I tried a code. But its not working. I add the code I used below. Please help. <ListBox Margin="0,0,0,0" Name="MyList" ScrollViewer.VerticalScrollBarVisibility="Disabled" ItemContainerStyle="{StaticResource ListBoxItemStyle1}"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel Background="Transparent" Margin="10,0,0

How to Change the SelectedItem Foreground Text of ListBox Item

别说谁变了你拦得住时间么 提交于 2019-12-06 09:56:46
问题 I have the following ListBox below. I am not sure how to change the Foreground of a selected item's textblock text when an item is selected, and then back to the original foreground color when an item is unselected (most likely occurring when another item in the ListBox is selected afterwards)? <ListBox Name="ListBox" SelectionMode="Single" ItemsSource="{Binding}" Margin="{Binding}" toolkit:TiltEffect.IsTiltEnabled="True" SelectionChanged="ListBox_SelectionChanged" > <ListBox.ItemsPanel>

Get a RETURN from a Invoke method

做~自己de王妃 提交于 2019-12-06 09:55:42
I am trying to read value from a listbox item that is on another thread. I tried to make a new method to run the invoke command, I can manage to send a command to the listbox like add via the invoke method but i cant seem to get a response, i cant seem to get the value of the item, i have tried a few ways, once i change it from a void to a string things start to get hairy... thread t1 = new thread(thethread) t1.start() public void thethread() { string text = readListBoxSelected(listBox1) + " lala" ; } public static string readListBoxSelected(ListBox listbox) { if (listbox.InvokeRequired) {

Silverlight Listbox Item Style

蹲街弑〆低调 提交于 2019-12-06 09:42:27
How would one go about styling a listbox such that the selection has a different text color than the default view? I've looked at this in several ways and because the ContentPresenter lacks a Foreground property. The default control template of the listbox provides several rectangles which one can use to adjust the highlight color. For example, with the default style a rectangle called BGColor3 has its opacity adjusted to get a highlight effect. Here is the bulk of my control template: <Grid> <Rectangle x:Name="BGColor2" Fill="{StaticResource HoverBrush}" Stroke="Black" StrokeThickness="1"

WPF ListBox Virtualization and Mulltiple types in the ItemsControl

牧云@^-^@ 提交于 2019-12-06 09:37:43
I've got a ListBox that is used to show items of multiple types (all derived from the same base type) that are bound to the ItemsSource through an ObservableCollection<T> . The performance of said ListBox is terrible. It appears that virtualization is disabled. According to: http://msdn.microsoft.com/en-us/library/cc716879(v=vs.110).aspx it seems that adding items of multiple types to the ItemsControl may be the problem. Here's my ListBox's style: <Style x:Key="{x:Type ListBox}" TargetType="{x:Type ListBox}"> <Setter Property="ScrollViewer.CanContentScroll" Value="true" /> <Setter Property=

ASP.NET mvc: Moving items between two listboxes

末鹿安然 提交于 2019-12-06 08:17:46
Currently I have 2 listboxes binding data from a database on my view... I've used a custom Viewmodel and it is not strongly-typed. Here's the code: <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<ProjectenII.Models.Domain.StudentModel>"%> <asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server"> IndexStudents </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> <h2>IndexStudents</h2> <div class="editor-field"> <%: Html.ListBox("IndexStudentsNormal", Model