Related
I have a long list coming from my Business logic which I need to display on the UI. As the list is long, I tried adding Scrollviewer but I am unable to scroll.
please find the XAML code below
<Grid Margin="0,32,0,0">
<TextBlock Text="{Binding IDC_WiFi, Source={StaticResource Resources}}" FontFamily="Segoe UI" FontSize="20" Foreground="#4cb5ab" HorizontalAlignment="Left" />
<Button Command="{Binding HardwareWifiAccordionCommand}" BorderThickness="0" Width="16" HorizontalAlignment="Right" Height="16" >
<Button.Background>
<ImageBrush ImageSource="{Binding AccordionImageHardwareWifi}" />
</Button.Background>
</Button>
</Grid>
<TextBlock Text="Klein's, Anil's" FontFamily="Segoe UI" FontSize="15" Foreground="#8fa3ad"/>
<StackPanel Height="200" Visibility="{Binding IsAccordionHardwareWifi, Converter={StaticResource Bool2Visible}}">
<ScrollViewer VerticalScrollBarVisibility="Auto">
<ItemsControl ItemsSource="{Binding WifiList,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" >
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Margin="0,32,0,0">
<Grid>
<Image Source="/Images/Assets/da_wifi1_16x16.png" Height="16" Width="16" HorizontalAlignment="Left" />
<TextBlock Margin="25,0,0,0" Text="{Binding NetworkName}" FontSize="15" Foreground="#FFFFFF" />
<TextBlock Text="" FontSize="15" Foreground="#8fa3ad" HorizontalAlignment="Right" />
</Grid>
<TextBlock Text="" FontSize="15" Foreground="#8fa3ad" HorizontalAlignment="Left" />
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</StackPanel>
Put it into a ScrollViewer.
<ScrollViewer>
<StackPanel >
</StackPanel>
</ScrollViewer>
As #StepUp points out you can just wrap it with a ScrollViewer but I believe this breaks virtualization. That's outside the scope of this question of course but it's something to keep in mind. If performance is likely to become an issue then I'd suggest implementing this as shown in the answer to this question.
The scrollviewer needed a Height to be set
<Grid Margin="0,32,0,0">
<TextBlock Text="{Binding IDC_WiFi, Source={StaticResource Resources}}" FontFamily="Segoe UI" FontSize="20" Foreground="#4cb5ab" HorizontalAlignment="Left" />
<Button Command="{Binding HardwareWifiAccordionCommand}" BorderThickness="0" Width="16" HorizontalAlignment="Right" Height="16" >
<Button.Background>
<ImageBrush ImageSource="{Binding AccordionImageHardwareWifi}" />
</Button.Background>
</Button>
</Grid>
<TextBlock Text="Klein's, Anil's" FontFamily="Segoe UI" FontSize="15" Foreground="#8fa3ad"/>
<StackPanel Height="200" Visibility="{Binding IsAccordionHardwareWifi, Converter={StaticResource Bool2Visible}}">
<ScrollViewer VerticalScrollBarVisibility="Auto" Height="350">
<ItemsControl ItemsSource="{Binding WifiList,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" >
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Margin="0,32,0,0">
<Grid>
<Image Source="/Images/Assets/da_wifi1_16x16.png" Height="16" Width="16" HorizontalAlignment="Left" />
<TextBlock Margin="25,0,0,0" Text="{Binding NetworkName}" FontSize="15" Foreground="#FFFFFF" />
<TextBlock Text="" FontSize="15" Foreground="#8fa3ad" HorizontalAlignment="Right" />
</Grid>
<TextBlock Text="" FontSize="15" Foreground="#8fa3ad" HorizontalAlignment="Left" />
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</StackPanel>
My List View contains nearly 10 items.I am able to show vertical scroll bar for list view. I am able to scroll the items by clicking on vertical scroll bar.
But What I want is When User placed control over a List View and trying to scroll the Items with Mouse that I am unable to do.
Please help me how can I solve this Issue.
Please give me your valuable Suggestions.
Here I am Adding My List View Code
<Border BorderThickness="0.5" CornerRadius="2" BorderBrush="Gray" Width="1250" Height="730" Margin="0,5,0,0">
<StackPanel Name="spStore" Visibility="Hidden" Background="AliceBlue">
<Label Content="{DynamicResource keyStore Management}" HorizontalAlignment="Center" FontSize="20" FontWeight="Bold" Foreground="DarkTurquoise"/>
<!--Scroll view to display list of items-->
<ScrollViewer VerticalScrollBarVisibility="Auto" Height="690" Visibility="Visible">
<StackPanel Orientation="Vertical">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Label Content="{DynamicResource keySTOCK MANAGEMENT}" Foreground="DarkTurquoise" FontSize="18" FontWeight="Bold" HorizontalAlignment="Left" Grid.Row="0"></Label>
<ListView Margin="0" Background="White" BorderThickness="0" Grid.Row="1" ScrollViewer.CanContentScroll="True" Name="lvstock" PreviewMouseWheel="lvstock_PreviewMouseWheel">
<ListViewItem MouseLeftButtonUp="StockDetails_Click" Background="AliceBlue" BorderBrush="Gray" BorderThickness="0.5,0.5,0.5,0" Cursor="Hand">
<StackPanel Orientation="Horizontal">
<Image Source="Images/Critical.png" Margin="0,0,5,0" Height="80" Width="80" />
<TextBlock VerticalAlignment="Center" FontWeight="Bold" FontSize="15" Text="{DynamicResource keyView Stocks}" ></TextBlock>
</StackPanel>
</ListViewItem>
<ListViewItem Background="AliceBlue" BorderBrush="Gray" MouseLeftButtonUp="StockVerificationDetails_Click" BorderThickness="0.5,0.5,0.5,0" Cursor="Hand">
<StackPanel Orientation="Horizontal">
<Image Source="Images/StockVerification.png" Margin="0,0,5,0" Height="80" Width="80" />
<TextBlock VerticalAlignment="Center" FontWeight="Bold" FontSize="15" Text="{DynamicResource keyVerify Stocks}"></TextBlock>
</StackPanel>
</ListViewItem>
<ListViewItem Background="AliceBlue" BorderBrush="Gray" MouseLeftButtonUp="VerifiedStockDetails_Click" BorderThickness="0.5,0.5,0.5,0.5" Cursor="Hand">
<StackPanel Orientation="Horizontal">
<Image Source="Images/StockVerification.png" Margin="0,0,5,0" Height="80" Width="80" />
<TextBlock VerticalAlignment="Center" FontWeight="Bold" FontSize="15" Text="{DynamicResource keyVerified Stock Report}"></TextBlock>
</StackPanel>
</ListViewItem>
</ListView>
<Label Content="{DynamicResource keyGOODS TRANSFER}" Foreground="DarkTurquoise" FontSize="18" FontWeight="Bold" HorizontalAlignment="Left" Grid.Row="2"></Label>
<ListView Margin="0" Background="White" BorderThickness="0" Grid.Row="3">
<ListViewItem Background="AliceBlue" BorderBrush="Gray" MouseLeftButtonUp="StockReceipt_Click" BorderThickness="0.5,0.5,0.5,0" Cursor="Hand">
<StackPanel Orientation="Horizontal">
<Image Source="Images/GoodsReceipts.png" Margin="0,0,5,0" Height="80" Width="80" />
<TextBlock VerticalAlignment="Center" FontWeight="Bold" FontSize="15" Text="{DynamicResource keyStock Receipt}"></TextBlock>
</StackPanel>
</ListViewItem>
<ListViewItem Background="AliceBlue" BorderBrush="Gray" MouseLeftButtonUp="StockIssue_Click" BorderThickness="0.5,0.5,0.5,0.5" Cursor="Hand">
<StackPanel Orientation="Horizontal">
<Image Source="Images/GoodsIssue.png" Margin="0,0,5,0" Height="80" Width="80" />
<TextBlock VerticalAlignment="Center" FontWeight="Bold" FontSize="15" Text="{DynamicResource keyStock Issue}"></TextBlock>
</StackPanel>
</ListViewItem>
<ListViewItem Background="AliceBlue" BorderBrush="Gray" Name="GoodsReturn" BorderThickness="0.5,0.5,0.5,0" MouseLeftButtonUp="GoodsReturn_MouseLeftButtonUp" Cursor="Hand">
<StackPanel Orientation="Horizontal">
<Image Source="Images/shipment_icon.png" Margin="0,0,5,0" Height="80" Width="80" />
<TextBlock VerticalAlignment="Center" FontWeight="Bold" FontSize="15" Text="{DynamicResource keyGoodsReturn}"></TextBlock>
</StackPanel>
</ListViewItem>
</ListView>
<Label Content="{DynamicResource keyGOODS PROCUREMENT}" Foreground="DarkTurquoise" FontSize="18" FontWeight="Bold" HorizontalAlignment="Left" Grid.Row="4"></Label>
<ListView Margin="0" Background="White" BorderThickness="0" Grid.Row="5">
<ListViewItem Background="AliceBlue" BorderBrush="Gray" BorderThickness="0.5,0.5,0.5,0" Cursor="Hand">
<StackPanel Orientation="Horizontal">
<Image Source="Images/PO.png" Margin="0,0,5,0" Height="80" Width="80" />
<TextBlock VerticalAlignment="Center" FontWeight="Bold" FontSize="15" Text="{DynamicResource keyPurchases}"></TextBlock>
</StackPanel>
</ListViewItem>
<ListViewItem Background="AliceBlue" BorderBrush="Gray" MouseLeftButtonUp="ProcurementReceipt_Click" BorderThickness="0.5,0.5,0.5,0.5" Cursor="Hand">
<StackPanel Orientation="Horizontal">
<Image Source="Images/GoodsReceipts.png" Margin="0,0,5,0" Height="80" Width="80" />
<TextBlock VerticalAlignment="Center" FontWeight="Bold" FontSize="15" Text="{DynamicResource keyReceipts}"></TextBlock>
</StackPanel>
</ListViewItem>
</ListView>
<Label Content="{DynamicResource keyDELIVERIES}" Foreground="DarkTurquoise" FontSize="18" FontWeight="Bold" HorizontalAlignment="Left" Grid.Row="6"></Label>
<ListView Margin="0" Background="White" BorderThickness="0" Grid.Row="7">
<ListViewItem Background="AliceBlue" BorderBrush="Gray" BorderThickness="0.5,0.5,0.5,0" Cursor="Hand">
<StackPanel Orientation="Horizontal">
<Image Source="Images/NewOrder.png" Margin="0,0,5,0" Height="80" Width="80" />
<TextBlock VerticalAlignment="Center" FontWeight="Bold" FontSize="15" Text="{DynamicResource keyOrders}"></TextBlock>
</StackPanel>
</ListViewItem>
<ListViewItem Background="AliceBlue" BorderBrush="Gray" BorderThickness="0.5,0.5,0.5,0.5" Cursor="Hand">
<StackPanel Orientation="Horizontal">
<Image Source="Images/shipment_icon.png" Margin="0,0,5,0" Height="80" Width="80" />
<TextBlock VerticalAlignment="Center" FontWeight="Bold" FontSize="15" Text="{DynamicResource keyShipments}">Shipments</TextBlock>
</StackPanel>
</ListViewItem>
</ListView>
</Grid>
</StackPanel>
</ScrollViewer>
</StackPanel>
</Border>
Thanks in advance.
The main problem with your XAML code is that MouseWheel event is handled by each inner ListView inside main ScrollViewer.
It's correct behavior in case when inner ListViews have theirs inner scrollbars (to prevent double scrolling - scrolling of inner scrollbar and scrolling of outer scrollbar).
As scrolling is not intended in inner ListViews, you can just assign special non scrollable Template for each inner ListView as presented in the following example:
Define the template for ListView in resources:
<Window.Resources>
<ControlTemplate x:Key="NonScrollableListView" TargetType="ListView">
<ItemsPresenter/>
</ControlTemplate>
</Window.Resources>
Then use it for each ListView inside the main ScrollViewier:
<ScrollViewer>
<StackPanel Orientation="Vertical">
<Grid>
<Grid.RowDefinitions>
<!--...-->
</Grid.RowDefinitions>
<!--...-->
<ListView Template="{StaticResource NonScrollableListView}" Margin="0" Background="White" BorderThickness="0" Grid.Row="1" Name="lvstock">
<!--...-->
</ListView>
<!--...-->
<ListView Template="{StaticResource NonScrollableListView}" Margin="0" Background="White" BorderThickness="0" Grid.Row="3">
<!--...-->
</ListView>
<!--...-->
<ListView Template="{StaticResource NonScrollableListView}" Margin="0" Background="White" BorderThickness="0" Grid.Row="5">
<!--...-->
</ListView>
</Grid>
</StackPanel>
</ScrollViewer>
you should change DragOver event for the ListView as follows:
private void ListView_DragOver(object sender, System.Windows.DragEventArgs e)
{
var lv = sender as ListView;
ScrollViewer sv = FindVisualChild<ScrollViewer>(lv);
double tolerance = 10;
double verticalPos = e.GetPosition(lv).Y;
double offset = 3;
if (verticalPos < tolerance)
{
sv.ScrollToVerticalOffset(sv.VerticalOffset - offset);
}
else if (verticalPos > lv.ActualHeight - tolerance)
{
sv.ScrollToVerticalOffset(sv.VerticalOffset + offset);
}
}
public static childItem FindVisualChild<childItem>(DependencyObject obj) where childItem : DependencyObject
{
// Search immediate children first (breadth-first)
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(obj); i++)
{
DependencyObject child = VisualTreeHelper.GetChild(obj, i);
if (child != null && child is childItem)
return (childItem)child;
else
{
childItem childOfChild = FindVisualChild<childItem>(child);
if (childOfChild != null)
return childOfChild;
}
}
return null;
}
After trying with many example I have found the solution and its working fine for me. What I observed is Inside Stack Panel scroll is not working but in Grid its working and instead of taking multiple list views I have Used only single List View. Thank you all for giving your valuable suggestions.
Here I am placing My working Code ... Once again Thank you guys for your suggestions.
<Grid Name="spStore" Visibility="Hidden" Background="AliceBlue">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Label Content="{DynamicResource keyStore Management}" HorizontalAlignment="Center" FontSize="20" FontWeight="Bold" Grid.Row="0" Foreground="DarkTurquoise"/>
<ListView Margin="0" Background="White" BorderThickness="0" Grid.Row="1" Name="lvstock">
<ListViewItem Background="AliceBlue" BorderBrush="Gray" BorderThickness="0.5,0.5,0.5,0" Cursor="Hand">
<StackPanel Orientation="Horizontal">
<Label Content="{DynamicResource keySTOCK MANAGEMENT}" Foreground="DarkTurquoise" FontSize="18" FontWeight="Bold" HorizontalAlignment="Left"></Label>
</StackPanel>
</ListViewItem>
<ListViewItem MouseLeftButtonUp="StockDetails_Click" Background="AliceBlue" BorderBrush="Gray" BorderThickness="0.5,0.5,0.5,0" Cursor="Hand">
<StackPanel Orientation="Horizontal">
<Image Source="Images/Critical.png" Margin="0,0,5,0" Height="80" Width="80" />
<TextBlock VerticalAlignment="Center" FontWeight="Bold" FontSize="15" Text="{DynamicResource keyView Stocks}" ></TextBlock>
</StackPanel>
</ListViewItem>
<ListViewItem Background="AliceBlue" BorderBrush="Gray" MouseLeftButtonUp="StockVerificationDetails_Click" BorderThickness="0.5,0.5,0.5,0" Cursor="Hand">
<StackPanel Orientation="Horizontal">
<Image Source="Images/StockVerification.png" Margin="0,0,5,0" Height="80" Width="80" />
<TextBlock VerticalAlignment="Center" FontWeight="Bold" FontSize="15" Text="{DynamicResource keyVerify Stocks}"></TextBlock>
</StackPanel>
</ListViewItem>
<ListViewItem Background="AliceBlue" BorderBrush="Gray" MouseLeftButtonUp="VerifiedStockDetails_Click" BorderThickness="0.5,0.5,0.5,0.5" Cursor="Hand">
<StackPanel Orientation="Horizontal">
<Image Source="Images/StockVerification.png" Margin="0,0,5,0" Height="80" Width="80" />
<TextBlock VerticalAlignment="Center" FontWeight="Bold" FontSize="15" Text="{DynamicResource keyVerified Stock Report}"></TextBlock>
</StackPanel>
</ListViewItem>
<ListViewItem Background="AliceBlue" BorderBrush="Gray" BorderThickness="0.5,0.5,0.5,0" Cursor="Hand">
<StackPanel Orientation="Horizontal">
<Label Content="{DynamicResource keyGOODS TRANSFER}" Foreground="DarkTurquoise" FontSize="18" FontWeight="Bold" HorizontalAlignment="Left"></Label>
</StackPanel>
</ListViewItem>
<ListViewItem Background="AliceBlue" BorderBrush="Gray" MouseLeftButtonUp="StockReceipt_Click" BorderThickness="0.5,0.5,0.5,0" Cursor="Hand">
<StackPanel Orientation="Horizontal">
<Image Source="Images/GoodsReceipts.png" Margin="0,0,5,0" Height="80" Width="80" />
<TextBlock VerticalAlignment="Center" FontWeight="Bold" FontSize="15" Text="{DynamicResource keyStock Receipt}"></TextBlock>
</StackPanel>
</ListViewItem>
<ListViewItem Background="AliceBlue" BorderBrush="Gray" MouseLeftButtonUp="StockIssue_Click" BorderThickness="0.5,0.5,0.5,0.5" Cursor="Hand">
<StackPanel Orientation="Horizontal">
<Image Source="Images/GoodsIssue.png" Margin="0,0,5,0" Height="80" Width="80" />
<TextBlock VerticalAlignment="Center" FontWeight="Bold" FontSize="15" Text="{DynamicResource keyStock Issue}"></TextBlock>
</StackPanel>
</ListViewItem>
<ListViewItem Background="AliceBlue" BorderBrush="Gray" Name="GoodsReturn" BorderThickness="0.5,0.5,0.5,0" MouseLeftButtonUp="GoodsReturn_MouseLeftButtonUp" Cursor="Hand">
<StackPanel Orientation="Horizontal">
<Image Source="Images/shipment_icon.png" Margin="0,0,5,0" Height="80" Width="80" />
<TextBlock VerticalAlignment="Center" FontWeight="Bold" FontSize="15" Text="{DynamicResource keyGoodsReturn}"></TextBlock>
</StackPanel>
</ListViewItem>
<ListViewItem Background="AliceBlue" BorderBrush="Gray" BorderThickness="0.5,0.5,0.5,0" Cursor="Hand">
<StackPanel Orientation="Horizontal">
<Label Content="{DynamicResource keyGOODS PROCUREMENT}" Foreground="DarkTurquoise" FontSize="18" FontWeight="Bold" HorizontalAlignment="Left"></Label>
</StackPanel>
</ListViewItem>
<ListViewItem Background="AliceBlue" BorderBrush="Gray" BorderThickness="0.5,0.5,0.5,0" Cursor="Hand">
<StackPanel Orientation="Horizontal">
<Image Source="Images/PO.png" Margin="0,0,5,0" Height="80" Width="80" />
<TextBlock VerticalAlignment="Center" FontWeight="Bold" FontSize="15" Text="{DynamicResource keyPurchases}"></TextBlock>
</StackPanel>
</ListViewItem>
<ListViewItem Background="AliceBlue" BorderBrush="Gray" MouseLeftButtonUp="ProcurementReceipt_Click" BorderThickness="0.5,0.5,0.5,0.5" Cursor="Hand">
<StackPanel Orientation="Horizontal">
<Image Source="Images/GoodsReceipts.png" Margin="0,0,5,0" Height="80" Width="80" />
<TextBlock VerticalAlignment="Center" FontWeight="Bold" FontSize="15" Text="{DynamicResource keyReceipts}"></TextBlock>
</StackPanel>
</ListViewItem>
<ListViewItem Background="AliceBlue" BorderBrush="Gray" BorderThickness="0.5,0.5,0.5,0" Cursor="Hand">
<StackPanel Orientation="Horizontal">
<Label Content="{DynamicResource keyDELIVERIES}" Foreground="DarkTurquoise" FontSize="18" FontWeight="Bold" HorizontalAlignment="Left"></Label>
</StackPanel>
</ListViewItem>
<ListViewItem Background="AliceBlue" BorderBrush="Gray" BorderThickness="0.5,0.5,0.5,0" Cursor="Hand">
<StackPanel Orientation="Horizontal">
<Image Source="Images/NewOrder.png" Margin="0,0,5,0" Height="80" Width="80" />
<TextBlock VerticalAlignment="Center" FontWeight="Bold" FontSize="15" Text="{DynamicResource keyOrders}"></TextBlock>
</StackPanel>
</ListViewItem>
<ListViewItem Background="AliceBlue" BorderBrush="Gray" BorderThickness="0.5,0.5,0.5,0.5" Cursor="Hand">
<StackPanel Orientation="Horizontal">
<Image Source="Images/shipment_icon.png" Margin="0,0,5,0" Height="80" Width="80" />
<TextBlock VerticalAlignment="Center" FontWeight="Bold" FontSize="15" Text="{DynamicResource keyShipments}">Shipments</TextBlock>
</StackPanel>
</ListViewItem>
</ListView>
</Grid>
ListView in ScrollViewer did not work for me, it helped to remove the ScrollViewer and set the scrollviewer.verticalscrollbarvisibility = true property of the ListView
Click Here to View ImageI am implementing Drag& Drop in wpf. I want when i dragged ListBoxItem From one Listbox to another. that listboxitem should be visible while dragging.Do i missing Something ?
XAML
<Grid x:Name="MainGrid" Width="{Binding ElementName=ProjectWindow,Path=ActualWidth}" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="19*" />
<ColumnDefinition Width="283*" />
<ColumnDefinition Width="59*" />
<ColumnDefinition Width="19*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="7*" />
<RowDefinition Height="83*" />
</Grid.RowDefinitions>
<Canvas Grid.Row="0" >
<Label Content="TM" FontSize="14" Foreground="White" FontFamily="segoe_uilight" Canvas.Left="118" Canvas.Top="-4"></Label>
<Label Content="smart" FontSize="26" Foreground="White" FontFamily="segoe_uilight"></Label>
<Label Content="Project" FontSize="26" Foreground="White" FontFamily="segoe_uilight" Canvas.Left="64" FontWeight="Bold"></Label>
<TextBlock Canvas.Left="164" Canvas.Top="15" Background="Black">
<Label Background="Black" Content="From" FontSize="12" Foreground="White" FontFamily="segoe_uilight" Canvas.Left="164" Canvas.Top="15" ></Label>
<DatePicker x:Name="StartDate" Width="100" Background="Black" Canvas.Left="204" Canvas.Top="15"></DatePicker>
<Label Background="Black" Content="Till" FontSize="12" Foreground="White" FontFamily="segoe_uilight" Canvas.Left="315" Canvas.Top="15" ></Label>
<DatePicker x:Name="EndDate" Width="100" Background="Black" Canvas.Left="344" Canvas.Top="15"></DatePicker>
<Label Background="Black" Content="My Activities" FontSize="12" Foreground="White" FontFamily="segoe_uilight" Canvas.Left="315" Canvas.Top="15" ></Label>
<CheckBox x:Name="ChckBoxMyActivities" Click="ChckBoxMyActivities_Click_1" Background="Black" Margin="0,0,0,5" Width="20"></CheckBox>
<Label Background="Black" Content="Project Component" FontSize="12" Foreground="White" FontFamily="segoe_uilight" Canvas.Left="315" Canvas.Top="15" ></Label>
<ComboBox x:Name="ComboBoxSubProjects" SelectionChanged="ComboBoxSubProjects_SelectionChanged_1" Background="Black" Margin="0,0,0,5" Width="100" ></ComboBox>
</TextBlock>
<Expander HorizontalAlignment="Right" FlowDirection="RightToLeft" Foreground="White" FontFamily="segoe_uilight" Width="200px" Canvas.Top="1" Canvas.Right="200" Canvas.Left="{Binding Source={x:Static SystemParameters.PrimaryScreenWidth}}" BorderBrush="#FF0A0909" BorderThickness="1,1,1,2" Background="#BF080707" Panel.ZIndex="99999">
<Expander.Header>
<StackPanel Orientation="Horizontal">
<Canvas Height="22" Width="172px" VerticalAlignment="Bottom">
<Label x:Name="LoginUserName" Margin="0px 0 0 0" HorizontalAlignment="Left" Foreground="White" FontFamily="segoe_uilight" BorderThickness="0"></Label>
<Image Source="img\icons\dropdown_user.png" Height="20px" Width="20px" RenderTransformOrigin="2.75,0.8" Canvas.Left="117" />
</Canvas>
</StackPanel>
</Expander.Header>
<!--<Expander.Content>
<TextBox Text="LoginUserName"></TextBox>
</Expander.Content>-->
<StackPanel Margin="10,4,0,0" >
<StackPanel Orientation="Horizontal">
<Label x:Name="lblSettings" Margin="49px 0 31px 0" HorizontalAlignment="Left" Content="Settings" Foreground="White" FontFamily="segoe_uilight" BorderThickness="0" RenderTransformOrigin="2.019,0.625">
</Label>
<Image Source="img\icons\setting.png" Height="20px" Width="20px" />
</StackPanel>
<!--<Label Margin="4" Content="Logout" />-->
<!--<Button x:Name="btnLogout" Margin="4" Content="Logout" Click="btnLogout_Click_1"></Button>-->
<StackPanel Orientation="Horizontal">
<Label x:Name="btnLogout" HorizontalAlignment="Left" Margin="54px 0 31px 0" Content="Logout" Foreground="White" FontFamily="segoe_uilight" BorderThickness="0">
</Label>
<Image Source="img\icons\logout.png" Height="20px" Width="20px" />
</StackPanel>
</StackPanel>
</Expander>
</Canvas>
<Canvas Grid.Column="0" Grid.Row="1" Background="Orange">
<StackPanel Canvas.Left="10" Background="Gray" Width="60" >
<Image Source="img\icons\information.png" Height="20px" Width="20px" />
<Label HorizontalAlignment="Center" Content="Info" Foreground="White" FontFamily="segoe_uilight" BorderThickness="0" >
</Label>
</StackPanel>
<StackPanel Canvas.Left="10" Canvas.Top="45" Background="Gray" Width="60" >
<Image Source="img\icons\Scheme.png" Height="20px" Width="20px" />
<Label HorizontalAlignment="Center" Content="Schema" Foreground="White" FontFamily="segoe_uilight" BorderThickness="0" >
</Label>
</StackPanel>
<StackPanel Canvas.Left="10" Canvas.Top="90" Background="Gray" Width="60" >
<Image Source="img\icons\Tavala.png" Height="20px" Width="20px" />
<Label HorizontalAlignment="Center" Content="Tavla" Foreground="White" FontFamily="segoe_uilight" BorderThickness="0" >
</Label>
</StackPanel>
</Canvas>
<Canvas x:Name="gd" Grid.Column="1" Grid.Row="1" Panel.ZIndex="-1" Background="Orange">
<Grid Width="{Binding ElementName=gd, Path=ActualWidth}" Panel.ZIndex="-1">
<Grid.RowDefinitions>
<RowDefinition />
</Grid.RowDefinitions>
<Canvas Grid.Column="1" Grid.Row="0" >
<Canvas x:Name="MainCanvas" Width="{Binding ElementName=gd,Path=ActualWidth}" >
<ListBox Height="{Binding ElementName=gd,Path=ActualHeight}" Width="{Binding ElementName=gd,Path=ActualWidth}" BorderThickness="0" >
<ListBoxItem>
<ListBox Loaded="icTodoList_Loaded_1" Background="Azure" SelectionChanged="icTodoList_SelectionChanged_1" Name="icTodoList" Height="50" Width="{Binding ElementName=gd,Path=ActualWidth}" >
<ListBox.ItemTemplate>
<DataTemplate>
<ListBox x:Name="Phases" BorderThickness="0">
<ListBoxItem>
<Canvas x:Name="PhaseCanvas" Height="20" Width="200" Margin="0,0,20,20" >
<StackPanel Orientation="Horizontal">
<TextBlock x:Name="txtPhaseID" TextAlignment="Center" FontWeight="Light" HorizontalAlignment="Center" FontSize="16" Foreground="Black" FontFamily="segoe_uilight" Text="{Binding PhaseTitle}" Height="20" Width="140" />
<Image Margin="20,0,0,0" Tag="{Binding PhaseID}" Source="img\icons\add_btn.png" Width="20" Height="15" MouseUp="Image_MouseUp_1"></Image>
<!--<TextBlock HorizontalAlignment="Left" FontFamily="segoe_uilight" FontStyle="Italic" Text="{Binding UserName}" Height="20" Width="180" />
<TextBlock TextWrapping="Wrap" HorizontalAlignment="Left" FontFamily="segoe_uilight" Text="{Binding ThreadDescription}" Height="45" Width="200" />-->
</StackPanel>
</Canvas>
</ListBoxItem>
</ListBox>
</DataTemplate>
</ListBox.ItemTemplate>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel IsItemsHost="True" Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>
</ListBoxItem>
<ListBoxItem>
<ListBox Loaded="ActivityListBox_Loaded_1" Background="Orange" Name="ActivityListBox" Height="{Binding ElementName=gd,Path=ActualHeight}" Width="{Binding ElementName=gd,Path=ActualWidth}" BorderThickness="0" >
<ListBox.ItemTemplate>
<DataTemplate>
<ListBox x:Name="InnerActivityListBox" Tag="{Binding PhaseID}" Width="225" Height="{Binding ElementName=gd,Path=ActualHeight}" Background="Orange" PreviewMouseLeftButtonDown="InnerActivityListBox_PreviewMouseLeftButtonDown_1" AllowDrop="True" DragEnter="InnerActivityListBox_DragEnter_1" Drop="InnerActivityListBox_Drop_1" DragOver="InnerActivityListBox_DragOver_1" BorderThickness="0">
<!--<ListBoxItem>-->
<!--<Canvas x:Name="ActivityCanvas" Width="200" Height="70" Background="White" >
<StackPanel Orientation="Vertical">
<TextBlock HorizontalAlignment="Left" FontWeight="Bold" Height="70" Width="10" Background="{Binding ColorDefination}" Margin="0"></TextBlock>
<TextBlock Margin="30,-70,0,0" Text="{Binding ActivityTitle}" FontWeight="Bold" ></TextBlock>
<TextBlock Margin="30,-60,0,0" Text="{Binding ProjectComponentTitle}" ></TextBlock>
<TextBlock Margin="30,-40,0,0" Text="1 Jan-3Mar" ></TextBlock>
</StackPanel>
<StackPanel Orientation="Horizontal" >
<Image Name="imgDesc" MouseUp="imgDesc_MouseUp_1" Source="img/icons/icon.png" Margin="20,50,0,0" Canvas.Left="15" Canvas.Top="50"></Image>
<Image Name="imgComments" MouseUp="imgComments_MouseUp_1" Source="img/icons/icon_1.png" Margin="20,50,0,0" Canvas.Left="45" Canvas.Top="50"></Image>
<Image Name="imgMembers" MouseUp="imgMembers_MouseUp_1" Source="img/icons/icon_2.png" Margin="20,50,0,0" Canvas.Left="75" Canvas.Top="50"></Image>
<Image Name="imglinks" MouseUp="imglinks_MouseUp_1" Source="img/icons/t3.png" Margin="20,50,0,0" Canvas.Left="105" Canvas.Top="50"></Image>
</StackPanel>
</Canvas>-->
<!--</ListBoxItem>-->
</ListBox>
</DataTemplate>
</ListBox.ItemTemplate>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel IsItemsHost="True" Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>
</ListBoxItem>
</ListBox>
<!--<ListBox Loaded="ActivityListBox_Loaded_1" Name="ActivityListBox" Height="{Binding ElementName=gd,Path=ActualHeight}" Canvas.Top="100" Width="{Binding ElementName=gd,Path=ActualWidth}" Background="Orange">
<ListBox.ItemTemplate >
<DataTemplate>
<ListBox x:Name="InnerActivityListBox">
<ListBoxItem>
<Canvas x:Name="ActivityCanvas" Width="200" Height="70" Background="White" >
<StackPanel Orientation="Vertical">
<TextBlock HorizontalAlignment="Left" FontWeight="Bold" Height="70" Width="10" Background="{Binding ColorDefination}" Margin="0"></TextBlock>
<TextBlock Margin="30,-70,0,0" Text="{Binding ActivityTitle}" FontWeight="Bold" ></TextBlock>
<TextBlock Margin="30,-60,0,0" Text="{Binding ProjectComponentTitle}" ></TextBlock>
<TextBlock Margin="30,-40,0,0" Text="1 Jan-3Mar" ></TextBlock>
</StackPanel>
<StackPanel Orientation="Horizontal" >
<Image Name="imgDesc" MouseUp="imgDesc_MouseUp_1" Source="img/icons/icon.png" Margin="20,50,0,0" Canvas.Left="15" Canvas.Top="50"></Image>
<Image Name="imgComments" MouseUp="imgComments_MouseUp_1" Source="img/icons/icon_1.png" Margin="20,50,0,0" Canvas.Left="45" Canvas.Top="50"></Image>
<Image Name="imgMembers" MouseUp="imgMembers_MouseUp_1" Source="img/icons/icon_2.png" Margin="20,50,0,0" Canvas.Left="75" Canvas.Top="50"></Image>
<Image Name="imglinks" MouseUp="imglinks_MouseUp_1" Source="img/icons/t3.png" Margin="20,50,0,0" Canvas.Left="105" Canvas.Top="50"></Image>
</StackPanel>
</Canvas>
</ListBoxItem>
</ListBox>
</DataTemplate>
</ListBox.ItemTemplate>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel IsItemsHost="True" Orientation="Vertical" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>-->
<!--<Canvas Width="200" Height="50" Background="White" Canvas.Left="46" Canvas.Top="10">
<TextBlock FontWeight="Bold" Height="50" Width="10" Canvas.Left="0" Background="Gray"></TextBlock>
<TextBlock Text="Header Style" FontWeight="Bold" Canvas.Top="2" Canvas.Left="15"></TextBlock>
<TextBlock Text="Schedule" Canvas.Top="14" Canvas.Left="15"></TextBlock>
<TextBlock Text="1 Jan-3Mar" Canvas.Top="7" Canvas.Left="110"></TextBlock>
<Image Source="img/icons/icon.png" Canvas.Left="15" Canvas.Bottom="5"></Image>
<Image Source="img/icons/icon_1.png" Canvas.Left="45" Canvas.Bottom="5"></Image>
<Image Source="img/icons/icon_2.png" Canvas.Left="75" Canvas.Bottom="5"></Image>
<Image Source="img/icons/t3.png" Canvas.Left="105" Canvas.Bottom="5"></Image>
</Canvas>-->
</Canvas>
</Canvas>
</Grid>
</Canvas>
<Canvas x:Name="cn" Grid.Column="2" Grid.Row="1" Background="White" MouseUp="Canvas_MouseUp_1">
<!--`ActivityInfo Popup up-->
<Canvas x:Name="ActivityInfo" Background="Green" Height="{Binding ElementName=cn,Path=ActualHeight}" MouseUp="ActivityInfo_MouseUp_1" Visibility="Hidden">
<TextBlock x:Name="projectdescrption" Foreground="#FFF3800C" FontFamily="segoe_uilight" FontSize="18" Text="Information" Canvas.Left="10" ></TextBlock>
<Canvas Background="White" Height="900" Width="200" Canvas.Top="50" Canvas.Left="10">
<StackPanel Width="200" Height="900" Background="White" Orientation="Vertical" >
<TextBlock x:Name="ActivityTitle" Text="Title" FontFamily="segoe_uilight" FontSize="18" Foreground="Black"></TextBlock>
<TextBlock x:Name="txtActivityTitle" Text="Page Design" FontFamily="segoe_uilight" FontSize="12" Foreground="Black"></TextBlock>
<TextBlock x:Name="ProjectCompnt" Text="Project Component" FontFamily="segoe_uilight" FontSize="18" Foreground="Black" Margin="0,20,0,0"></TextBlock>
<TextBlock x:Name="txtProjectCompnt" Text="Project Component Design" FontFamily="segoe_uilight" FontSize="12" Foreground="Black"></TextBlock>
<TextBlock x:Name="Phase" Text="Phase" FontFamily="segoe_uilight" FontSize="18" Foreground="Black" Margin="0,20,0,0"></TextBlock>
<TextBlock x:Name="txtPhase" Text="Phase Design" FontFamily="segoe_uilight" FontSize="12" Foreground="Black"></TextBlock>
<TextBlock x:Name="Start" Text="Start" FontFamily="segoe_uilight" FontSize="18" Foreground="Black" Margin="0,20,0,0"></TextBlock>
<TextBlock x:Name="txtStart" Text="2014-1-16" FontFamily="segoe_uilight" FontSize="12" Foreground="Black"></TextBlock>
<TextBlock x:Name="End" Text="End" FontFamily="segoe_uilight" FontSize="18" Foreground="Black" Margin="0,20,0,0"></TextBlock>
<TextBlock x:Name="txtEnd" Text="2014-2-16" FontFamily="segoe_uilight" FontSize="12" Foreground="Black"></TextBlock>
<TextBlock x:Name="Activitydescrption" Foreground="Black" FontFamily="segoe_uilight" FontSize="18" Text="Description" Margin="0,20,0,0"></TextBlock>
<TextBlock x:Name="txtActivitydescrption" HorizontalAlignment="Left" Text="Loresum lipsum Loresum lipsum Loresum lipsum lipsum Loresum lipsum lipsum Loresum lipsum" Height="70" Width="180" FontFamily="segoe_uilight" TextWrapping="Wrap" Margin="0,0,0,0" FontSize="12" Foreground="Black"></TextBlock>
<TextBlock x:Name="ActivityRequirement" Foreground="Black" FontFamily="segoe_uilight" FontSize="18" Text="Requirement" Margin="0,20,0,0"></TextBlock>
<TextBlock x:Name="txtActivityRequirement" HorizontalAlignment="Left" Text="Loresum lipsum Loresum lipsum Loresum lipsum lipsum Loresum lipsum lipsum Loresum lipsum" Height="70" Width="180" FontFamily="segoe_uilight" TextWrapping="Wrap" Margin="0,0,0,0" FontSize="12" Foreground="Black"></TextBlock>
<Button x:Name="btnsave" Content="Save" Foreground="Black" Height="30" Width="100" HorizontalAlignment="Right" Background="#FFF3800C"></Button>
</StackPanel>
</Canvas>
</Canvas>
<!--`Activity Comments-->
<Canvas x:Name="Comments" Background="White" Height="{Binding ElementName=cn,Path=ActualHeight}" MouseUp="Comments_MouseUp_1" Visibility="Hidden">
<TextBlock x:Name="ActivityComments" Foreground="#FFF3800C" FontFamily="segoe_uilight" FontSize="23" Text="Comments" Canvas.Left="35"></TextBlock>
<TextBox x:Name="txtComments" Height="110" Width="200" BorderBrush="Black" TextWrapping="Wrap" Canvas.Top="40" Canvas.Left="5" VerticalScrollBarVisibility="Visible" AcceptsReturn="True"></TextBox>
<Button x:Name="btnsavecomments" Content="Send" Foreground="Black" Height="30" Width="100" Canvas.Top="170" Canvas.Left="35" Background="#FFF3800C"></Button>
<ListBox Canvas.Top="220" BorderBrush="White">
<ListBoxItem>
<!--<ListBox.ItemTemplate>
<DataTemplate>-->
<Canvas Width="220" Height="620">
<StackPanel Width="200" Height="Auto" Canvas.Top="20" Orientation="Vertical" >
<Border BorderThickness="2,2,2,2" CornerRadius="4" Background="#E26806">
<TextBlock x:Name="txtthreadComments" Height="Auto" Width="190" TextWrapping="Wrap" Background="#E26806" Text="g rg rg r g rg rg rg rg er gre ger ger g g gr" Foreground="White" ></TextBlock>
</Border>
<Image x:Name="imgthread" Height="30" Width="30" Margin="-100,-12,0,0" Source="D:\Amrit\Working Code\smart Info WPF app\SmartInfo\SmartAccount\SmartAccount\img\tol_tip.jpg"></Image>
<TextBlock x:Name="threadtime" Text="2014-6-7 12:00" HorizontalAlignment="Stretch" Margin="0,0,10,0" FontStyle="Italic" Height="20" Width="150" Foreground="Black" FontSize="16"></TextBlock>
<TextBlock x:Name="threadPostedBy" Text="Amrit Verma" Height="20" Width="150" Foreground="Black" FontStyle="Italic" FontWeight="Bold" FontSize="15"></TextBlock>
</StackPanel>
</Canvas>
</ListBoxItem>
<!--</DataTemplate>
</ListBox.ItemTemplate>-->
</ListBox>
</Canvas>
<!-- Assigned Memebres -->
<Canvas x:Name="AssignedMemebres" Background="White" Height="{Binding ElementName=cn,Path=ActualHeight}" Visibility="Hidden">
<TextBlock x:Name="Memebres" Foreground="#FFF3800C" FontFamily="segoe_uilight" FontSize="18" Text="Assigned Members" Canvas.Left="30"></TextBlock>
<ListBox Canvas.Top="40" BorderBrush="White">
<ListBoxItem>
<!--<ListBox.ItemTemplate>
<DataTemplate>-->
<Canvas Width="220" Height="620">
<TextBlock x:Name="AssignMemeber" Foreground="Black" FontFamily="segoe_uilight" FontSize="14" Text="+ Assign Memeber" FontStyle="Italic" Canvas.Left="12" Canvas.Top="-3"></TextBlock>
<StackPanel Width="200" Height="Auto" Canvas.Top="20" Orientation="Vertical" Canvas.Left="20">
<TextBlock FontFamily="segoe_uilight" FontSize="16" x:Name="txtassignedto" Text="Amrit Verma" FontWeight="Bold"></TextBlock>
<TextBlock FontFamily="segoe_uilight" FontSize="16" x:Name="txtassignedrole" Text="Developer" ></TextBlock>
<TextBlock FontFamily="segoe_uilight" FontSize="12" x:Name="Email" Text="Email" Margin="0,10,0,0"></TextBlock>
<TextBlock FontFamily="segoe_uilight" FontSize="14" x:Name="txtEmail" Text="Amrit#gmail.com" FontStyle="Italic"></TextBlock>
<TextBlock FontFamily="segoe_uilight" FontSize="12" x:Name="Phone" Text="Phone" Margin="0,10,0,0"></TextBlock>
<TextBlock FontFamily="segoe_uilight" FontSize="14" x:Name="txtPhone" Text="555-111 442 213" FontStyle="Italic"></TextBlock>
<TextBlock FontFamily="segoe_uilight" FontSize="12" x:Name="WorkingHours" Text="Working Hours" Margin="0,10,0,0"></TextBlock>
<TextBlock FontFamily="segoe_uilight" FontSize="14" x:Name="txtWorkingHours" Text="9:00 - 12:00" FontStyle="Italic"></TextBlock>
<TextBlock FontFamily="segoe_uilight" FontSize="12" x:Name="WorkingDays" Text="Working Days" Margin="0,10,0,0"></TextBlock>
<TextBlock FontFamily="segoe_uilight" FontSize="14" x:Name="txtWorkingDays" Text="Mon-Sat" FontStyle="Italic"></TextBlock>
</StackPanel>
</Canvas>
</ListBoxItem>
<!--</DataTemplate>
</ListBox.ItemTemplate>-->
</ListBox>
</Canvas>
</Canvas>
<Canvas Grid.Column="3" Grid.Row="1" Background="Orange" >
<StackPanel Canvas.Left="0" Background="Gray" Width="60" MouseUp="StackPanel_MouseUp_1" x:Name="stackpnlinfo">
<Image Source="img\icons\icon.png" Height="20px" Width="20px" />
<!--<Image Source="img\btn_img.jpg" Height="45px" Width="60px" />-->
<Label HorizontalAlignment="Center" Content="Info" Foreground="White" FontFamily="segoe_uilight" BorderThickness="0" ></Label>
</StackPanel>
<StackPanel Canvas.Left="0" Canvas.Top="45" Background="Gray" Width="60" MouseUp="StackPanel_MouseUp_2" x:Name="stackpnlcomment">
<Image Source="img\icons\icon_1.png" Height="20px" Width="20px" />
<Label HorizontalAlignment="Center" Content="Comments" Foreground="White" FontFamily="segoe_uilight" BorderThickness="0" >
</Label>
</StackPanel>
<StackPanel Canvas.Left="0" Canvas.Top="90" Background="Gray" Width="60" >
<Image Source="img\icons\icon_2.png" Height="20px" Width="20px" />
<Label HorizontalAlignment="Center" Content="Files" Foreground="White" FontFamily="segoe_uilight" BorderThickness="0" >
</Label>
</StackPanel>
<StackPanel Canvas.Left="0" Canvas.Top="135" Background="Gray" Width="60" x:Name="AssignedMembrs" MouseUp="AssignedMembrs_MouseUp_1">
<Image Source="img\icons\at.png" Height="20px" Width="20px" />
<Label HorizontalAlignment="Center" Content="Assigned Members" Foreground="White" FontFamily="segoe_uilight" BorderThickness="0" >
</Label>
</StackPanel>
</Canvas>
</Grid>
c#
private void InnerActivityListBox_PreviewMouseLeftButtonDown_1(object sender, MouseButtonEventArgs e)
{
ListBox Phaseitem = (ListBox)sender as ListBox;
if (_dragged != null)
return;
UIElement element = Phaseitem.InputHitTest(e.GetPosition(Phaseitem)) as UIElement;
while (element != null)
{
if (element is ListBoxItem)
{
_dragged = (ListBoxItem)element;
break;
}
element = VisualTreeHelper.GetParent(element) as UIElement;
}
SourcePhaseID = Phaseitem.Tag.ToString();
Globallb = Phaseitem;
Globallbi = _dragged;
Phaseitem.Items.Remove(_dragged);
}
private void InnerActivityListBox_DragEnter_1(object sender, DragEventArgs e)
{
if (_dragged == null || e.Data.GetDataPresent(DataFormats.Text, true) == false)
e.Effects = DragDropEffects.None;
else
e.Effects = DragDropEffects.All;
}
private void InnerActivityListBox_Drop_1(object sender, DragEventArgs e)
{
ListBox Phaseitem = (ListBox)sender as ListBox;
DestinationPhaseID = Phaseitem.Tag.ToString();
Phaseitem.Items.Add(_dragged);
}
private void InnerActivityListBox_DragOver_1(object sender, DragEventArgs e)
{
e.Effects = DragDropEffects.Move;
}
If this is you are trying to achieve. This also include designing your own Adorner to be shown as Ghost Perview while dragging
http://www.codeproject.com/Articles/43702/Drag-and-Drop-in-WPF-Part-II
and this article has vanilla code and doing exactly what you want
http://www.essentialobjects.com/doc/5/controls/treeview/dragdrop.aspx#list_box
I have this ListView and I'm using a DataTemplate (as you can see) for items.
How can i add column names to the ListView with this ItemTemplate definition?
I cannot use that GridViewColumn definition, because this ListView uses lazy data loading, so when there are too many rows, it fetches them on demand. GridViewColumn somehow does not function with this lazy loading.
<ListView Grid.Row="3">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid x:Name="grid" Background="Transparent" MinWidth="580" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="220" />
<ColumnDefinition Width="100" />
<ColumnDefinition Width="100" />
<ColumnDefinition Width="70"/>
<ColumnDefinition Width="80"/>
</Grid.ColumnDefinitions>
<TextBlock VerticalAlignment="Center" Grid.Column="0" Text="{Binding Path=Benutzer.Value.Code}"/>
<TextBlock VerticalAlignment="Center" Grid.Column="1" Text="{Binding Path=Nachname}"/>
<TextBlock VerticalAlignment="Center" Grid.Column="2" Text="{Binding Path=Vorname}"/>
<TextBlock VerticalAlignment="Center" Grid.Column="3">
<TextBlock.Text>
<Binding Path="GeburtDate" StringFormat="{}{0:d}"/>
</TextBlock.Text>
</TextBlock>
<Button VerticalAlignment="Center" Grid.Column="4" Style="{StaticResource StyleEditButton}" Content="Öffnen..." Tag="{Binding}" Click="OpenPersonButton_Click"/>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ListView>
I don't think there is any point in using a ListView if, as you say, you cannot use GridView (or any other view). I would exchange ListView for ItemsControl (or ListBox if you need a selectable item or any of the other things that ListBox offers).
If what you say is true, you could just use a stack panel to position a header row above your data rows:
<StackPanel>
<!-- Header -->
<StackPanel Orientation="Horizontal">
<TextBlock Width="220" TextAlignment="Center" Text="Code" />
<TextBlock Width="100" TextAlignment="Center" Text="Nachname" />
<TextBlock Width="100" TextAlignment="Center" Text="Vorname" />
<TextBlock Width="70" TextAlignment="Center" Text="GeburtDate" />
</StackPanel>
<!-- Data rows -->
<ItemsControl>
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" MinWidth="580">
<TextBlock Width="220" TextAlignment="Center" Text="{Binding Path=Benutzer.Value.Code}" />
<TextBlock Width="100" TextAlignment="Center" Text="{Binding Path=Nachname}" />
<TextBlock Width="100" TextAlignment="Center" Text="{Binding Path=Vorname}" />
<TextBlock Width="70" TextAlignment="Center" Text="{Binding Path=GeburtDate, StringFormat={0:d}}" />
<Button VerticalAlignment="Center" Grid.Column="4" Style="{StaticResource StyleEditButton}" Content="Öffnen..." Tag="{Binding}" Click="OpenPersonButton_Click"/>
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>
Hope that helps. You might also like to read about virtualizing panels. That might provide the kind of laziness you're talking about.
So, let's say I have a DataTemplate:
<DataTemplate x:Key="ProjectsDataItemTemplate">
<ComboBoxItem x:Name="ProjectComboBox"
Opacity="1" HorizontalAlignment="Stretch"
Foreground="#FF80BBD2"
VerticalAlignment="Center" VerticalContentAlignment="Center"
Background="Transparent"
Style="{DynamicResource ComboBoxItemStyle1}">
<StackPanel>
<Label Content="{Binding Name}" Height="32" VerticalContentAlignment="Top"
FontWeight="Bold" Foreground="#FFFEF9F9" AllowDrop="True" />
<TextBlock Text="{Binding Description}"
Foreground="#FF80BBD2"
Padding="5,0,0,10"
FontStyle="Italic" />
</StackPanel>
</ComboBoxItem>
</DataTemplate>
In this case, the Label and the TextBlock both overlap the clickable area for the ComboBoxItem. How do I ignore and/or pass a click through to the ComboBoxItem when I click one of its child controls?
Just set the IsHitTestVisible property to false for those elements:
<DataTemplate x:Key="ProjectsDataItemTemplate">
<ComboBoxItem x:Name="ProjectComboBox"
Opacity="1"
HorizontalAlignment="Stretch"
Foreground="#FF80BBD2"
VerticalAlignment="Center"
VerticalContentAlignment="Center"
Background="Transparent"
Style="{DynamicResource ComboBoxItemStyle1}">
<StackPanel>
<Label IsHitTestVisible="False"
Content="{Binding Name}"
Height="32"
VerticalContentAlignment="Top"
FontWeight="Bold"
Foreground="#FFFEF9F9"
AllowDrop="True" />
<TextBlock IsHitTestVisible="False"
Text="{Binding Description}"
Foreground="#FF80BBD2"
Padding="5,0,0,10"
FontStyle="Italic" />
</StackPanel>
</ComboBoxItem>
</DataTemplate>