I'm working on some XAML/WPF where we create a template of the form that then get compiled into a dll and this dll is then used by a blackbox application to render the form to the user.
Ideally, I should be able to this entirely in XAML, but I am not fully aware of what can and cannot be done in XAML.
I have the following:
<cad:SortableListView.View>
<GridView DataGridRow.Selected="">
<GridViewColumn Header="Message #" cad:SortableListView.SortPropertyName="MessageId" DisplayMemberBinding="{Binding Path=MessageId}"/>
<GridViewColumn Header="Critical" cad:SortableListView.SortPropertyName="Message.IsReceiptRequested" CellTemplate="{StaticResource criticalCellTemplate}"/>
<GridViewColumn Header="Date/Time" cad:SortableListView.SortPropertyName="Message.SendingTime" DisplayMemberBinding="{Binding Path=Message.SendingTime.LocalDateTime, StringFormat={}{0:G}}"/>
<GridViewColumn Header="Subject" cad:SortableListView.SortPropertyName="Message.Subject" DisplayMemberBinding="{Binding Path=Message.Subject}" Width="140"/>
<GridViewColumn Header="From Terminal" cad:SortableListView.SortPropertyName="Message.SendingTerminal" DisplayMemberBinding="{Binding Path=Message.SendingTerminal}"/>
<GridViewColumn Header="Sender" cad:SortableListView.SortPropertyName="Message.SendingEmployeeId" DisplayMemberBinding="{Binding Path=Message.SendingEmployeeId}"/>
<GridViewColumn Header="Priority" cad:SortableListView.SortPropertyName="Message.Priority" DisplayMemberBinding="{Binding Path=Message.Priority}"/>
<GridViewColumn Header="Event" cad:SortableListView.SortPropertyName="Message.LocalEvent.AgencyEventId" DisplayMemberBinding="{Binding Path=Message.LocalEvent.AgencyEventId}"/>
</GridView>
</cad:SortableListView.View>
....
More code
....
<TextBlock Grid.Row="3" Grid.Column="0" TextAlignment="Left" Margin="25,0,0,5">
Reply:
</TextBlock>
<TextBox Grid.Row="3" Grid.Column="1" Text="{Binding Path=ReplyText}" HorizontalAlignment="Stretch" Margin="10,0,30,5"/>
<Button Grid.Row="3" Grid.Column="2" Margin="5,0,30,5" DockPanel.Dock="Right"
Command="{Binding Path=Acknowledge.Command}"
cad:CreateCommandBinding.Command="{Binding Path=Acknowledge}" IsDefault="True">
Acknowledge
</Button>
I need it so that when a row is selected from the grid, the cursor has to jump to the text box and when "Enter" is pressed, the button click event is fired. I think I managed to do that by setting it as the default (IsDefault = "true"). Its the only button on the screen so I'm not too worried about something else firing.
Again, the ideal is to be able to do this in pure XAML, but if a file needs to be attached, kindly show me how to reference this code behind file.
Thank you
Related
Ì want to write a software where there is a grid layout inside a scrollview.
I already hardcoded it, but I think I need to find a solution to make this dynamic! How can I manage to do this! I am pretty new to C# and WPF. I post a screenshot and my code so you can see what I am trying to achieve.
DataGrid is probably the best thing to use here, although you can also do it with a ListView using a GridView as the view:
<ListView ItemsSource="{Binding Items}">
<ListView.View>
<GridView>
<GridViewColumn Header="Name" DisplayMemberBinding="{Binding Name}" />
<GridViewColumn Header="Age" DisplayMemberBinding="{Binding Age}" />
<GridViewColumn Header="Gender" DisplayMemberBinding="{Binding Gender}" />
</GridView>
</ListView.View>
</ListView>
I've been messing around with checkboxes and listview in my wpf application. Selecting multiple items seems to work properly, but when I click on an item and not on its checkbox it selects the item and deselects all the others previously selected, how can I fix this ?
Here's my code:
<ListView Name="NewPlace_ActionsList" HorizontalAlignment="Left" Height="254" Margin="10,74,0,0" VerticalAlignment="Top" Width="389" >
<ListView.View>
<GridView>
<GridViewColumn>
<GridViewColumn.CellTemplate>
<DataTemplate>
<CheckBox Tag="{Binding Id}" IsChecked="{Binding RelativeSource={RelativeSource AncestorType={x:Type ListViewItem}}, Path=IsSelected}" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="Codice" DisplayMemberBinding="{Binding Path=Id}" />
<GridViewColumn Header="Nome" DisplayMemberBinding="{Binding Path=Name}" />
<GridViewColumn Header="Descrizione" DisplayMemberBinding="{Binding Path=Desc}" />
</GridView>
</ListView.View>
</ListView>
What do you want to accomplish? The system behaves exactly to what you coded: the checkbox is selected only in the selected row. Because the Checkbox "follows" the IsSelected of the row (ListViewItem).
I had created the listview in below manner
using grid view init;
i need that when mouseover on the gridview item i need to get that username details in the popup window , i am able to generate the popupwindow
except that Hover username in the listview
this is my sample code so please try to provide this information
<ListView AlternationCount="2" removed="#FFB6CCD8" Canvas.Left="15" Canvas.Top="77" FontSize="13" Height="43" IsSynchronizedWithCurrentItem="True" ItemContainerStyle="{DynamicResource ListViewItemContainerStyle}" ItemsSource="{Binding}" Name="checkedListView1" SelectionMode="Single" TabIndex="2" Width="269" ItemTemplate="{StaticResource ItemDataTemplate}"
SelectionChanged="checkedListView_SelectionChanged" MouseEnter="checkedListView1_MouseEnter" MouseMove="checkedListView1_MouseMove">
<ListView.View>
<GridView>
<GridViewColumn DisplayMemberBinding="{Binding Path=empid}" Header="CardID" Width="1" />
<GridViewColumn DisplayMemberBinding="{Binding Path=username}" Width="200" />
<GridViewColumn >
<GridViewColumn.CellTemplate>
<DataTemplate>
<Image Source="/WPF.Themes.Demo;component/Images/Status-user-online.ico" Width="20" Height="20"></Image>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
here i am using the listview in the Gridview manner , so please try to provide the Information to get the Username which was presented in the Gridviewcolumn when mouse cursor Hover in the listview
Thank you.
I have the Xaml code that show everything correctly but I want to make it so the first column's content is bold:
<c:TreeView Name="JobList" SelectedItemChanged="JobList_SelectedItemChanged">
<c:TreeView.Columns>
<GridViewColumn Header="Jobs" Width="350" DisplayMemberBinding="{Binding Name}"/>
<GridViewColumn Header="Goal" Width="100" DisplayMemberBinding="{Binding Goal}"/>
<GridViewColumn Header="Messages" Width="120" DisplayMemberBinding="{Binding MessageType}"/>
</c:TreeView.Columns>
</c:TreeView>
Also can I also do this based on whether the item in the first column has sub treeview nodes or not?
I havent used the TreeListView, but usually you can put other UIElements in the header. Give this a try:
<GridViewColumn Header="Jobs" Width="350" DisplayMemberBinding="{Binding Name}">
<GridViewColumn.Header>
<TextBlock FontWeight="Bold" Text="{Binding Goal}"></TextBlock>
</GridViewColumn.Header>
</GridViewColumn>
How can I make a ListView imitate the ListView in Windows Explorer on the right side. Like how can I get icons in the ListView and get the arrows?
You can find the icons by using Google Image search. To create the ListView, you could do something like this is XAML:
<Grid>
<ListView ItemsSource="{Binding ListViewSource}">
<ListView.View>
<GridView>
<GridViewColumn Width="25">
<GridViewColumn.CellTemplate>
<DataTemplate>
<Image Source="{Binding Icon}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="Name" DisplayMemberBinding="{Binding FileName}" Width="250"/>
<GridViewColumn Header="Date Modified" DisplayMemberBinding="{Binding DateModified}" Width="100"/>
<GridViewColumn Header="Type" DisplayMemberBinding="{Binding FileType}" Width="100"/>
<GridViewColumn Header="Size" DisplayMemberBinding="{Binding FileSize}" Width="100"/>
</GridView>
</ListView.View>
</ListView>
</Grid>
The next step is to create an ObservableCollection to hold all of the items in your list and call it ListViewSource. You can populate this collection with actual FileDirectory information, or your own kind of list. You'll then want to create your logic as to what happens when you doubleclick on an item. Since your question didn't specify to what detail you want the ListView to work, I'm going to stop there. Let us know if you want it to behave just like Windows Explorer, and we'll try to help you out.