I would like to enable or disable a field when a specific value in the combobox is selected:
In my xaml, I have a ListBox (ListToTransfert)wich is filled by dragging items from another Listbox (ListViewContents).
The ListToTransfert got 3 fields: Name, Gapand Time.
The field Namecannot be edited while the 2 others can be.
When the combobox has its value changed to Gapor to Time, I want the appropriate column to be enabled while the other one is disabled.
Here is the code of my XAML:
<!-- ListViewContents -->
<Label Content="Contents" Background="White" HorizontalContentAlignment="Center" HorizontalAlignment="Left" Margin="11,16,0,0" VerticalAlignment="Top" Width="400" Height="31"/>
<ListView Background="#bdc3c7" x:Name="ListViewContents" SelectionMode="Single" Margin="11,51.826,0,11" HorizontalAlignment="Left" Width="400">
<ListView.View>
<GridView >
<GridViewColumn Header="Name" Width="350" DisplayMemberBinding="{Binding Name}"/>
</GridView>
</ListView.View>
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseDoubleClick">
<command:EventToCommand Command="{Binding TransferContent}"
CommandParameter="{Binding SelectedItem, ElementName=ListViewContents}" />
</i:EventTrigger>
</i:Interaction.Triggers>
<Label Content="Label" Height="100" Width="100"/>
</ListView>
<!-- ListToTransfert -->
<TextBox Style="{StaticResource {x:Static ToolBar.TextBoxStyleKey}}"
HorizontalContentAlignment="Center"
HorizontalAlignment="Left" Margin="851,16,0,0"
VerticalAlignment="Top" Width="400" Height="31" Text="{Binding groupName}" />
<ListView Background="#bdc3c7" x:Name="ListToTransfert" ItemsSource="{Binding ContentsToTransfer}" HorizontalAlignment="Right" Width="400" Margin="0,51.826,21,11">
<ListView.View>
<GridView>
<GridViewColumn Header="Amount" >
<GridViewColumn.HeaderTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition SharedSizeGroup="A" />
</Grid.ColumnDefinitions>
<TextBlock Foreground="Black" Background="AliceBlue" Text="{Binding}"/>
</Grid>
</DataTemplate>
</GridViewColumn.HeaderTemplate>
<GridViewColumn.CellTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition SharedSizeGroup="A" />
</Grid.ColumnDefinitions>
<TextBlock Foreground="Black" Background="AliceBlue" HorizontalAlignment="Right" Text="{Binding Path=Name}"/>
</Grid>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="Gap"></GridViewColumn>
<GridViewColumn Header="Time"></GridViewColumn>
</GridView>
</ListView.View>
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseDoubleClick">
<command:EventToCommand Command="{Binding DeleteContent}"
CommandParameter="{Binding SelectedItem, ElementName=ListToTransfert}" />
</i:EventTrigger>
</i:Interaction.Triggers>
</ListView>
My combobox is not yet created since i'm not sure if there is a solution for this problem, tho there is always one.
Can you propose me a XAML solution to do that?
This can be done either via a group of RadioButtons or a single ComboBox.
RadioButton
If you don't need to control this behavior from the view model, you can use the following :
<RadioButton x:Name="TimeRadioButton" Content="Time" />
<GridViewColumn Header="Gap">
<GridViewColumn.CellTemplate>
<DataTemplate>
<Grid>
<TextBlock IsEnabled="{Binding IsChecked, ElementName=GapRadioButton}"/>
</Grid>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
Alternatively, you can add EnableGapColumn/EnableTimeColumn on your view model. However, it would be better if you create an enum to define this behavior :
public enum TransfertViewType
{
Gap, Time
}
And change your bindings with EnumToBooleanConverter:
<!-- put this in a resource -->
<converter:EnumToBooleanConverter x:Key="EnumToBooleanConverter" />
<RadioButton Content="Time" IsChecked="{Binding ViewType, Converter={StaticResource EnumToBooleanConverter}, ConverterParameter={x:Static vm:YourViewModel.TransfertViewType}}"/>
<TextBlock IsEnabled="{Binding ViewType, Converter={StaticResource EnumToBooleanConverter}, ConverterParameter={x:Static vm:YourViewModel.TransfertViewType}}"/>
ComboBox
It would pretty much the same as the second part of RadioButton section, except that you will need to create an IEnumerable<TransfertViewType> as the ItemsSource for the ComboBox. Or, an IDictionary<TransfertViewType, string> if you like to customize the description a little bit.
<!-- for ienumerable -->
<ComboBox ItemsSource="{Binding TransfertViewTypes}"
SelectedValue="{Binding ViewType}" />
<!-- for idictionary -->
<ComboBox ItemsSource="{Binding TransfertViewTypes}"
DisplayMemberPath="Value" SelectedValuePath="Key"
SelectedValue="{Binding ViewType}" />
Related
I want to step into next row if I hit a specific key like enter or the arrows on keyboard.I can't find any material on this topic. Could anyone help me out?
I tried with tabnavigation from msdn, but first I want to go on keydown directly to the textbox and second I need to use the arrows and / or the enter key I mentioned earlier.
Thank you!
<ListView AlternationCount="2"
x:Name="lstItems" ItemsSource="{Binding Path=Notes, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
Height="300"
KeyboardNavigation.TabNavigation="Cycle"
KeyboardNavigation.AcceptsReturn="False"
SelectedItem="{Binding Path=Current, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
FontSize="{StaticResource h2FontSize}" Margin="5">
<ListView.View>
<GridView x:Name="gridView" ColumnHeaderContainerStyle="{StaticResource itemsListViewHeader}"
>
<GridViewColumn x:Name="Column1" Header="{x:Static p:Resources.DENOMINATION}" Width="200">
<GridViewColumn.HeaderContainerStyle>
<Style TargetType="GridViewColumnHeader" BasedOn="{StaticResource itemsListViewHeaderLeft}">
</Style>
</GridViewColumn.HeaderContainerStyle>
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock x:Name="BankNoteValue" HorizontalAlignment="Right" Text="{Binding Path=BankNoteValue, StringFormat={}{0:0.##}}" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn x:Name="Column2" Header="{x:Static p:Resources.PC}" Width="200">
<GridViewColumn.HeaderContainerStyle>
<Style TargetType="GridViewColumnHeader" BasedOn="{StaticResource itemsListViewHeaderLeft}">
</Style>
</GridViewColumn.HeaderContainerStyle>
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBox Width="{Binding ElementName=Column2, Path=ActualWidth, UpdateSourceTrigger=PropertyChanged}" Name="tbAmount"
Text="{Binding Path=BankNotePiece, StringFormat={}{0:#.###}, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" IsEnabled="{Binding isChecked}">
</TextBox>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
I am new to WPF and try to do the following:
I have a ListView with a ItemsSource using a ViewModel.
Inside, there is a GridView with Columns. Each Column represents a Preoperty of the View Model. But the Description is optional and can be rather long. So I want to use a Expander. My Problem is, that I can only manage the expander to be as big as the Name-Column. But I want the expander to be as big as the whole row.
Here are 2 Images to clarify what I want.
My current State:
https://i.stack.imgur.com/ZNA4v.png
What I want to achieve:
https://i.stack.imgur.com/ZmFq1.png
I tried "grouping the GridView" but without success... See here
http://technico.qnownow.com/grouping-gridview-wpf/
Here's my Code
<Window ...>
<Window.Resources>
...
</Window.Resources>
<DockPanel>
<StackPanel DockPanel.Dock="Top">
...
</StackPanel>
<Grid>
<ListView Grid.RowSpan="4" DockPanel.Dock="Top" Margin="10" ItemsSource="{Binding MyView}">
<ListView.ItemContainerStyle>
<Style TargetType="{x:Type ListViewItem}">
<Setter Property="BorderBrush" Value="Black"></Setter>
<Setter Property="BorderThickness" Value="0,0,0,1"></Setter>
<Setter Property="Focusable" Value="False" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="VerticalAlignment" Value="Top"></Setter>
<Setter Property="VerticalContentAlignment" Value="Top"></Setter>
</Style>
</ListView.ItemContainerStyle>
<!-- New GridView -->
<ListView.View>
<GridView>
<!--Number-->
<GridViewColumn Header="#">
<GridViewColumn.CellTemplate>
<DataTemplate DataType="viewModel:MyViewModel">
<TextBlock Text="{Binding Model.Number, StringFormat='#{0}', Mode=OneWay}"
Width="20" TextAlignment="Left" Margin="5" VerticalAlignment="Top" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<!--ErrorLevel-->
<GridViewColumn Header="" Width="45">
<GridViewColumn.CellTemplate>
<DataTemplate DataType="viewModel:MyViewModel">
<Image Source="{Binding Model.ErrorLevel, Converter={StaticResource ErrorLevelToImageConverter}, Mode=OneWay}"
ToolTip="{Binding Model.ErrorLevel, Mode=OneWay}" Width="20" Margin="5" VerticalAlignment="Top" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<!--ID-->
<GridViewColumn Header="ID">
<GridViewColumn.CellTemplate>
<DataTemplate DataType="viewModel:MyViewModel">
<TextBlock TextAlignment="Center" Margin="5" Width="50" VerticalAlignment="Top" >
<Hyperlink NavigateUri="{Binding Model.Hyperlink, Mode=OneWay}"
Command="{Binding HyperlinkCommand}">
<TextBlock Text="{Binding Model.Id, Mode=OneWay}" />
</Hyperlink>
</TextBlock>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<!--Name-->
<GridViewColumn Header="Name" Width="500" >
<GridViewColumn.CellTemplate>
<DataTemplate DataType="viewModel:MyViewModel">
<Expander ToolTip="Expand" ExpandDirection="Down" Foreground="Black" VerticalAlignment="Top">
<Expander.Header>
<TextBlock Text="{Binding Model.Name, Mode=OneWay}"
HorizontalAlignment="{Binding HorizontalAlignment, RelativeSource={RelativeSource AncestorType=ContentPresenter}, Mode=OneWayToSource}"
TextAlignment="Left" Margin="5" TextWrapping="Wrap" VerticalAlignment="Top" />
</Expander.Header>
<GroupBox Header="Description" FontWeight="Bold" >
<TextBlock Text="{Binding Model.Description, Mode=OneWay}" TextWrapping="Wrap"
FontWeight="Normal" TextAlignment="Left" Margin="5" />
</GroupBox>
</Expander>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<!-- Module-->
<GridViewColumn Header="Module" >
<GridViewColumn.CellTemplate>
<DataTemplate DataType="viewModel:MyViewModel">
<TextBlock Text="{Binding Model.Module, Mode=OneWay}"
TextAlignment="Center" Margin="5" Width="100" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
</Grid>
</DockPanel>
Once again, i am new to WPF, MVVM, DataBinding and all this. So please try to make your answer as detailed as possible. I tried many things, but they didn't work out.
You could add the following GridViewColumn at the left side (top in XAML) to your GridView
<GridViewColumn Header="" Width="30">
<GridViewColumn.CellTemplate>
<DataTemplate DataType="viewModel:MyViewModel">
<Expander Margin="-5,2,-5000,0" HorizontalAlignment="Left" Width="{Binding Path=ActualWidth, RelativeSource={RelativeSource AncestorType={x:Type ItemsPresenter}}}">
<GroupBox Header="Description" FontWeight="Bold" Margin="0,0,5,0">
<TextBlock Text="{Binding Model.Description}" FontWeight="Normal" TextWrapping="Wrap" />
</GroupBox>
</Expander>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
This is GridViewColumncontains an empty Header which simply shows the Expander-Arrow in the GridViewRows.
The Expander itself is left aligned and has a huge negative Margin on the right side, so it can draw its content outside of the right boundary. The width is set to the ActualWidth of the ItemsPresenter of your GridView. With this Width you can limit the content to the current visible Width of the GridView (Or you can set it to an absolute value like 500).
And finally a preview of this Column
OK, the fact that the expander is not stretchable is because of the non stretchable parent control. You have a column 'Name' in your gridview with a fixed width and a expander added as a child. As far as i know the child control cannot extend beyond the parent control if this is not truth im sure someone will correct this. I don't know what the best way is to achieve your goal but to give you some inspiration i made a small example.
So, to give you a example if how this could work:
Edit: You can just set negative margins on your expander like so:
<Expander ToolTip="Expand" ExpandDirection="Down" Margin="-100,0,-300,0" Foreground="Black" VerticalAlignment="Top">
Thanks to #LittleBit for this tip.
<ListView x:Name="lsttest" ItemsSource="{Binding persons}">
<ListViewItem>
<StackPanel>
<ListView>
<ListView.View>
<GridView>
<GridViewColumn Header="#1" Width="50">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}"
Width="20" TextAlignment="Left" Margin="5" VerticalAlignment="Top" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="Test 2" Width="50">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}"
Width="20" TextAlignment="Left" Margin="5" VerticalAlignment="Top" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
<Expander ToolTip="Expand" ExpandDirection="Down" Foreground="Black" VerticalAlignment="Top">
<Expander.Header>
<TextBlock Text="{Binding Model.Name, Mode=OneWay}"
HorizontalAlignment="{Binding HorizontalAlignment, RelativeSource={RelativeSource AncestorType=ContentPresenter}, Mode=OneWayToSource}"
TextAlignment="Left" Margin="5" TextWrapping="Wrap" VerticalAlignment="Top" />
</Expander.Header>
<GroupBox Header="Description" FontWeight="Bold" Width="{Binding ActualWidth, ElementName=lsttest}">
<TextBlock Text="{Binding Name, Mode=OneWay}" TextWrapping="Wrap"
FontWeight="Normal" TextAlignment="Left" Margin="5" />
</GroupBox>
</Expander>
</StackPanel>
</ListViewItem>
</ListView>
The result:
I am trying to do some simple thing in WPF but can't find the way to do it.
I have a ComboBox in a DataGrid header to filter data. The data is binded to a GrouBy statement of all my data.
These show some CheckBox The XAML code is:
<DataGridTextColumn x:Name="Type"
Binding="{Binding TypeOfData, Mode=OneTime}"
SortMemberPath="TypeOfData"
IsReadOnly="true"
CanUserSort="true">
<DataGridTextColumn.Header>
<DockPanel>
<Label Content="Type Of Data"
DockPanel.Dock="Left"/>
<ComboBox x:Name="comboBoxType"
DockPanel.Dock="Right"
SelectionChanged="comboBoxType_SelectionChanged">
<ComboBox.ItemTemplate>
<DataTemplate>
<StackPanel x:Name="itemsComboBox">
<CheckBox Name="checkBoxType"
IsChecked="False"
Content="{Binding Key}"
Unchecked="FilterChange"
Checked="FilterChange"/>
</StackPanel>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
</DockPanel>
</DataGridTextColumn.Header>
</DataGridTextColumn>
The code behind fore binding is:
comboBoxType.ItemsSource = allData.GroupBy(data=> data.TypeOfData).OrderBy(grp=> grp.Key);
And this work.
But now I want to add 2 button to check and uncheck all at the end or at the start of the ComboBox but I can't seem to find how to add those static button in a dynamic data template.
Edit Answer to grek40:
I want the buttons in the combobox Items before or after the checkboxes.
CompositeCollection could help but I can't seem to make it work.
Thank You
Replace the DockPanel with a Grid that has several ColumnDefinitions:
<DataGridTextColumn x:Name="Type" Binding="{Binding TypeOfData, Mode=OneTime}" SortMemberPath="TypeOfData" IsReadOnly="true" CanUserSort="true">
<DataGridTextColumn.Header>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Label Content="Type Of Data" />
<ComboBox x:Name="comboBoxType"
Grid.Column="1"
SelectionChanged="comboBoxType_SelectionChanged">
<ComboBox.ItemTemplate>
<DataTemplate>
<StackPanel x:Name="itemsComboBox">
<CheckBox Name="checkBoxType"
IsChecked="False"
Content="{Binding Key}"
Unchecked="FilterChange"
Checked="FilterChange"/>
</StackPanel>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<Button Content="Check"
Grid.Column="2" />
</Grid>
</DataGridTextColumn.Header>
</DataGridTextColumn>
How do I make a ListView in WPF fill all of the available space? I have tried lots and lots of things but none of them work.
Most recently I tried nesting the ListView in a DockPanel and then using a binding on the ListView to grab the DockPanel's ActualHeight. This works well but there are other controls in the container and they need to be accommodated.
I don't really want to have to write OnControlLoaded() and OnControlResized() events and resize the ListView in code. What can I do?
Here is the XAML with the offending SortableListView on line 10.
<DockPanel>
<StackPanel DockPanel.Dock="Top" Orientation="Horizontal" Margin="15 5 5 5">
<Button x:Name="btnAddCost" Padding="3" ToolTip="Add Cost" Margin="0 0 5 0" Click="btnAddCost_Click" >
Add Cost
</Button>
<Button x:Name="btnDeleteCost" Padding="3" ToolTip="Delete Cost" Margin="0 0 5 0" Click="btnDeleteCost_Click" IsEnabled="{Binding ElementName=lvCosts, Path=SelectedItem, Converter={StaticResource falseWhenNullConverter}}" >
Delete Cost
</Button>
</StackPanel>
<ctrls:SortableListView DockPanel.Dock="Top" x:Name="lvCosts" Margin="1" SelectionMode="Single" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
ContextMenuOpening="lvCosts_ContextMenuOpening"
DefaultActionSelected="lvCosts_DefaultActionSelected" MouseDoubleClick="lvCosts_MouseDoubleClick"
ItemsSource="{Binding Booking.AdditionalCosts}">
<ListView.View>
<GridView>
<GridViewColumn Header="Category" Width="100" DisplayMemberBinding="{Binding Path=Category.Name}" ctrls:SortableListView.SortPropertyName="Category">
</GridViewColumn>
<GridViewColumn Header="Supplier" Width="110" DisplayMemberBinding="{Binding Path=Supplier}" ctrls:SortableListView.SortPropertyName="Supplier">
</GridViewColumn>
<GridViewColumn Header="Buy Currency" Width="100" DisplayMemberBinding="{Binding Path=BuyCurrency.Name}" ctrls:SortableListView.SortPropertyName="BuyCurrency">
</GridViewColumn>
<GridViewColumn Header="Buy Price" Width="110" DisplayMemberBinding="{Binding Path=BuyPrice}" ctrls:SortableListView.SortPropertyName="BuyPrice">
</GridViewColumn>
<GridViewColumn Header="Sell Currency" Width="100" DisplayMemberBinding="{Binding Path=SellCurrency.Name}" ctrls:SortableListView.SortPropertyName="SellCurrency">
</GridViewColumn>
<GridViewColumn Header="Sell Price" Width="110" DisplayMemberBinding="{Binding Path=SellPrice}" ctrls:SortableListView.SortPropertyName="SellPrice">
</GridViewColumn>
<GridViewColumn Header="Margin" Width="180" DisplayMemberBinding="{Binding Path=Margin}" ctrls:SortableListView.SortPropertyName="Margin">
</GridViewColumn>
</GridView>
</ListView.View>
<ListView.ContextMenu>
<ContextMenu x:Name="mnuCostOptions" >
<MenuItem x:Name="mniAddCost" Header="_Add Cost" Click="mniAddCost_Click" ></MenuItem>
<MenuItem x:Name="mniEditCost" Header="View/_Edit Cost" Click="mniEditCost_Click" IsEnabled="False"></MenuItem>
<MenuItem x:Name="mniDeleteCost" Header="_Delete Cost" Click="mniDeleteCost_Click" IsEnabled="False"></MenuItem>
</ContextMenu>
</ListView.ContextMenu>
</ctrls:SortableListView>
<StackPanel DockPanel.Dock="Bottom" Orientation="Horizontal" Margin="0,0,0,5">
<TextBlock Grid.Row="3" Grid.Column="0">Total Buy Price:</TextBlock>
<rdf:NumericTextBox Grid.Row="3" Grid.Column="1" IsEnabled="False" MinWidth="50" Margin="0,0,10,0">
<rdf:NumericTextBox.Text>
<Binding Path="Booking.AdditionalCostsBuyPriceConvertedTotal" UpdateSourceTrigger="PropertyChanged"
Converter="{StaticResource currencyStringConverter}" ConverterParameter="#0.00" Mode="OneWay">
</Binding>
</rdf:NumericTextBox.Text>
</rdf:NumericTextBox>
<TextBlock Grid.Row="3" Grid.Column="0">Total Sell Price:</TextBlock>
<rdf:NumericTextBox Grid.Row="3" Grid.Column="1" IsEnabled="False" MinWidth="50" Margin="0,0,10,0">
<rdf:NumericTextBox.Text>
<Binding Path="Booking.AdditionalCostsSellPriceConvertedTotal" UpdateSourceTrigger="PropertyChanged"
Converter="{StaticResource currencyStringConverter}" ConverterParameter="#0.00" Mode="OneWay">
</Binding>
</rdf:NumericTextBox.Text>
</rdf:NumericTextBox>
<TextBlock Grid.Row="3" Grid.Column="0">Total Margin:</TextBlock>
<rdf:NumericTextBox Grid.Row="3" Grid.Column="1" IsEnabled="False" MinWidth="50" Margin="0,0,10,0">
<Binding Path="Booking.AdditionalCostsMarginConvertedTotal" UpdateSourceTrigger="PropertyChanged"
Converter="{StaticResource currencyStringConverter}" ConverterParameter="#0.00" Mode="OneWay">
</Binding>
</rdf:NumericTextBox>
<TextBlock Grid.Column="1" Grid.Row="3" HorizontalAlignment="Right" Text="{Binding Path=Booking.SellPriceCurrency.Name, Mode=OneWay}" Margin="0,0,0,0"/>
</StackPanel>
</DockPanel>
Thanks, M
You have a DockPanel containing:
StackPanel
a SortableListView and
another StackPanel
1 & 2 are both docked to the Top; 3 is docked to the Bottom. That means you have nothing in the middle, ie. between 2 & 3. Rearrange the order of the elements to place the SortableListView third, and remove its DockPanel.Dock property so it takes up the remaining space.
In other words, instead of what you have now:
<DockPanel>
<StackPanel DockPanel.Dock="Top" ... >
<ctrls:SortableListView DockPanel.Dock="Top" ... >
<StackPanel DockPanel.Dock="Bottom" ... >
</DockPanel>
change it to this:
<DockPanel>
<StackPanel DockPanel.Dock="Top" ... >
<StackPanel DockPanel.Dock="Bottom" ... >
<ctrls:SortableListView ... >
</DockPanel>
This is my wpf file. I want the GridView to support multiple selections.
<ListView Name="deviceListBox"
Width="630"
Height="282"
HorizontalAlignment="Center"
VerticalAlignment="Center"
ItemsSource="{Binding Items}"
SelectionChanged="deviceListBox_SelectionChanged"
SelectionMode="Single">
<ListView.View>
<GridView>
<GridView.Columns>
<GridViewColumn>
<GridViewColumn.HeaderTemplate>
<DataTemplate>
<Label Width="15"
Height="25"
Margin="10,0,0,0"
HorizontalAlignment="center"
VerticalAlignment="Center" />
</DataTemplate>
</GridViewColumn.HeaderTemplate>
<GridViewColumn.CellTemplate>
<DataTemplate>
<Grid>
<controls:PresenceIndicator Width="35"
Height="30"
Margin="7,0,0,0"
HorizontalAlignment="center"
VerticalAlignment="Center"
PhotoDisplayMode="Large"
SingleClickAction="ShowContactDetails"
Source="{Binding Path=SipURI}" />
</Grid>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn>
<GridViewColumn.HeaderTemplate>
<DataTemplate>
<Label Width="95"
Height="25"
Margin="10,0,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Content="Username"
Foreground="Black" />
</DataTemplate>
</GridViewColumn.HeaderTemplate>
<GridViewColumn.CellTemplate>
<DataTemplate>
<Grid>
<Label Height="30"
Margin="7,0,0,0"
HorizontalAlignment="left"
VerticalAlignment="Center"
Content="{Binding Path=Username}"
Foreground="Black" />
</Grid>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn>
Change your SelectionMode to Multiple or Extended. See this MSDN post
Set the DataGrid.SelectionMode:
<DataGrid SelectionMode="Single" ...