How to populate a ListView with composite UI elements? - c#

I have a ListView like this:
<ListView x:Name="Thumbnails" HorizontalContentAlignment ="Center" VerticalContentAlignment="Top" Padding="0" Background ="#81AFD3" Grid.Row="6" Grid.Column="6" Grid.ColumnSpan="10" Grid.RowSpan="27" ScrollViewer.VerticalScrollBarVisibility="Visible">
<ListView.ItemContainerStyle>
<Style TargetType="{x:Type ListViewItem}">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="IsSelected" Value="True"/>
</Trigger>
</Style.Triggers>
</Style>
</ListView.ItemContainerStyle>
</ListView>
Now, I would like to populate it with 5 elements. Each element is a a Grid that contains one image and two buttons. So I defined this Grid in UserControl.Resourceslike this:
</UserControl.Resources>
<Grid x:Key="ThumbnailElement">
<Grid.RowDefinitions>
<RowDefinition Height="1*" />
<RowDefinition Height="1*" />
<RowDefinition Height="1*" />
<RowDefinition Height="1*" />
<RowDefinition Height="1*" />
<RowDefinition Height="1*" />
<RowDefinition Height="1*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
</Grid.ColumnDefinitions>
<Image Name="thumbImage" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="14" Grid.RowSpan="7" Source="/Assets/ImportAssets/Test.jpg"></Image>
<Button Name="slide_ON_OFF" Grid.Row="0" Grid.Column="10" Grid.ColumnSpan="4" Grid.RowSpan="4">
<Button.Template>
<ControlTemplate>
<Grid RenderTransformOrigin="0.5,0.5" x:Name="bg">
<Image Source="/MS_Show_Assets/ImportAssets/Visible_ON.png"/>
</Grid>
</ControlTemplate>
</Button.Template>
</Button>
<Button Name="fadein_ON_OFF" Grid.Row="3" Grid.Column="10" Grid.ColumnSpan="4" Grid.RowSpan="4">
<Button.Template>
<ControlTemplate>
<Grid RenderTransformOrigin="0.5,0.5" x:Name="bg">
<Image x:Name ="main_image" Source="/MS_Show_Assets/ImportAssets/Bulletpoint_ON.png"/>
</Grid>
</ControlTemplate>
</Button.Template>
</Button>
</Grid>
</UserControl.Resources>
How would I do this, and only in XAML, without using code behind?

Use ContentControl to swap your views. Example:
<UserControl xmlns:Views="....View">
<UserControl.Resources>
<ControlTemplate x:Key="DefultTemplate">
<Views:DefultView/>
</ControlTemplate>
</UserControl.Resources>
<ListView x:Name="Thumbnails" HorizontalContentAlignment ="Center" VerticalContentAlignment="Top" Padding="0" Background ="#81AFD3" Grid.Row="6" Grid.Column="6" Grid.ColumnSpan="10" Grid.RowSpan="27" ScrollViewer.VerticalScrollBarVisibility="Visible">
<ListView.ItemContainerStyle>
<Style TargetType="ContentControl">
<Setter Property="Template" Value="{StaticResource DefultTemplate}" />
</Style>
</ListView.ItemContainerStyle>
<ListItem Background="Red" Margin="5 5 5 5"/>
<ListItem Background="Red" Margin="5 5 5 5"/>
<ListItem Background="Red" Margin="5 5 5 5"/>
<ListItem Background="Red" Margin="5 5 5 5"/>
<ListItem Background="Red" Margin="5 5 5 5"/>
<ListItem Background="Red" Margin="5 5 5 5"/>
</ListView>
</UserControl>
DefultTemplate:
<UserControl ....>
<....>
</UserControl>
If we don't now the number of items, we can use:
<ListView ItemsSource="{Binding SomeCollection}" x:Name="Thumbnails" HorizontalContentAlignment ="Center" VerticalContentAlignment="Top" Padding="0" Background ="#81AFD3" Grid.Row="6" Grid.Column="6" Grid.ColumnSpan="10" Grid.RowSpan="27" ScrollViewer.VerticalScrollBarVisibility="Visible">
<ListView.ItemContainerStyle>
<Style TargetType="ContentControl">
<Setter Property="Template" Value="{StaticResource DefultTemplate}" />
</Style>
</ListView.ItemContainerStyle>
</ListView>

Related

WPF: Content of round-cornered border not being round-cornered

I have a round-cornered border and I am trying to make its contents to be also round-cornered but my attempts are not working. Basically I am doing a kind of custom MessageBox but simpler, only with one image icon, a text and a button. No title bar. Image icon is changing depending on the type of message.
Stackpanel corners overlaps over border so border corners are not showing rounded.
ATTEMPT #1:
<Border x:Name="MyCustomMessageBox"
CornerRadius="5,5,5,5"
Grid.ZIndex="3"
Visibility="{Binding IsMessageBoxShown, Mode=TwoWay, Converter={StaticResource BoolToVis}}"
Width="auto" Height="auto"
HorizontalAlignment="Center"
VerticalAlignment="Center"
BorderBrush="DarkBlue" BorderThickness="1"
Background="White">
<Border.Effect>
<DropShadowEffect />
</Border.Effect>
<Grid Background="Blue">
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="50"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Row="0" Grid.Column="0" Orientation="Horizontal" Background="WhiteSmoke">
<Grid>
<Image VerticalAlignment="Center" HorizontalAlignment="Left"
Source="/Common.MyImages;component/Images/Info.png"
Height="48" Width="48" Margin="20,10">
<Image.Style>
<Style TargetType="{x:Type Image}">
<Setter Property="Source" Value="/Common.MyImages;component/Images/Info.png"/>
<Style.Triggers>
<DataTrigger Binding="{Binding MsgType}" Value="1">
<Setter Property="Source" Value="/Common.MyImages;component/Images/Error.png"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Image.Style>
</Image>
</Grid>
<TextBlock Width="280" Margin="0,0,10,0" VerticalAlignment="Center" HorizontalAlignment="Left"
Background="Transparent" FontSize="12" TextWrapping="Wrap"><Run Text="This is a message"/>
</TextBlock>
</StackPanel>
<Button x:Name="btnCustomMessageBox" Grid.Row="1" Grid.Column="0"
Click="btnCustomMessageBox_Click"
HorizontalAlignment="Center" Margin="10" Width="80" Content="Ok" Visibility="Visible"/>
</Grid>
</Border>
ATTEMPT #2:
As explained here, I have tried also but without success.
<Grid>
<Grid.OpacityMask>
<VisualBrush Visual="{Binding ElementName=MyCustomMessageBox}" />
</Grid.OpacityMask>
<!-- Here goes all the above border code -->
</Grid>
The following should solve your issue.
<Border x:Name="MyCustomMessageBox"
CornerRadius="5"
Visibility="{Binding IsMessageBoxShown, Mode=TwoWay, Converter={StaticResource BoolToVis}}"
Width="auto" Height="auto"
HorizontalAlignment="Center"
VerticalAlignment="Center"
BorderBrush="DarkBlue"
BorderThickness="1"
Background="blue">
<Border.Effect>
<DropShadowEffect />
</Border.Effect>
<Grid> <!-- removed the Background here. Only letting borders provide background. -->
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="50"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<!--
Added a border to fill the top part of the grid with the
whitesmoke color using a borderradius on the top.
Also note that the Background from the stackpanel was removed.
-->
<Border
Grid.Row="0" Grid.Column="0"
Name="mask"
Background="WhiteSmoke"
CornerRadius="5,5,0,0"
/>
<StackPanel Grid.Row="0" Grid.Column="0" Orientation="Horizontal">
<Grid>
<Image VerticalAlignment="Center" HorizontalAlignment="Left"
Source="/Common.MyImages;component/Images/Info.png"
Height="48" Width="48" Margin="20,10">
<Image.Style>
<Style TargetType="{x:Type Image}">
<Setter Property="Source" Value="/Common.MyImages;component/Images/Info.png"/>
<Style.Triggers>
<DataTrigger Binding="{Binding MsgType}" Value="1">
<Setter Property="Source" Value="/Common.MyImages;component/Images/Error.png"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Image.Style>
</Image>
</Grid>
<TextBlock Width="280" Margin="0,0,10,0" VerticalAlignment="Center" HorizontalAlignment="Left"
Background="Transparent" FontSize="12" TextWrapping="Wrap"><Run Text="This is a message"/>
</TextBlock>
</StackPanel>
<Button x:Name="btnCustomMessageBox" Grid.Row="1" Grid.Column="0"
Click="btnCustomMessageBox_Click"
HorizontalAlignment="Center" Margin="10" Width="80" Content="Ok" Visibility="Visible"/>
</Grid>
</Border>

How can I make a border only on one/two sides?

I got to make 4 buttons near each other, I've done it by grid, but I've asked to add borders at only one/two sides (like in the next screenshot)
With borders
So far I've done that:
Without
The code:
<Page
x:Class="App1.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:App1"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Page.Resources>
<Style TargetType="Button" x:Key="NavagtionButtons">
<Setter Property="Height" Value="100"/>
<Setter Property="FontSize" Value="18"/>
<Setter Property="Background" Value="Black" />
<Setter Property="Foreground" Value="White" />
<Setter Property="VerticalAlignment" Value="Stretch" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
</Style>
</Page.Resources>
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid.RowDefinitions>
<RowDefinition Height="100"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Button Style="{StaticResource NavagtionButtons}" Grid.Row="0" Grid.Column="0" >
<Button.Content>
<StackPanel Orientation="Horizontal">
<Image Source="Assets/donut-icon.png" Stretch="None" />
<TextBlock Text="Donut" Margin="10,15,0,0" />
</StackPanel>
</Button.Content>
</Button>
<Button Style="{StaticResource NavagtionButtons}" Grid.Row="0" Grid.Column="1" >
<Button.Content>
<StackPanel Orientation="Horizontal">
<Image Source="Assets\coffee-icon.png" Stretch="None"/>
<TextBlock Text="Coffe" Margin="10,15,0,0" />
</StackPanel>
</Button.Content>
</Button>
<Button Style="{StaticResource NavagtionButtons}" Grid.Row="0" Grid.Column="2" >
<Button.Content>
<StackPanel Orientation="Horizontal">
<Image Source="Assets\schedule-icon.png" Stretch="None" />
<TextBlock Text="Schedule" Margin="10,15,0,0"/>
</StackPanel>
</Button.Content>
</Button>
<Button Style="{StaticResource NavagtionButtons}" Grid.Row="0" Grid.Column="3">
<Button.Content>
<StackPanel Orientation="Horizontal">
<Image Source="Assets\complete-icon.png" Stretch="None" />
<TextBlock Text="Complete" Margin="10,15,0,0"/>
</StackPanel>
</Button.Content>
</Button>
</Grid>
So how can I add borders only on the sides he showed?

C# Tab Index in TreeViewItem element

I have a simple TreeView, I'm not able to navigate in the TextBox with the focus. Do you have any suggestions???
I have updated the xaml code for give you more details. I hope this is helpful.
More Detail.
More Detail.
More Detail.
More Detail.
More Detail.
<StackPanel Orientation="Vertical" Margin="5">
<StackPanel Orientation="Vertical">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" SharedSizeGroup="Column1"/>
<ColumnDefinition Width="5" SharedSizeGroup="Column2"/>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="28"/>
<RowDefinition Height="28"/>
</Grid.RowDefinitions>
<GridSplitter Grid.Column="1" Grid.RowSpan="2147483647" HorizontalAlignment="Left" Width="5" VerticalContentAlignment="Stretch" IsTabStop="False"/>
<TextBlock Name="Number" Grid.Row="0" Grid.Column="0" Text="Number"/>
<TextBox x:Name="TxtNumber" Grid.Row="0" Grid.Column="2" Text="{Binding Number}" TabIndex="0"/>
<TextBlock Name="Name" Grid.Row="1" Grid.Column="0" Text="Name"/>
<TextBox Grid.Row="1" Grid.Column="2" Text="{Binding Name}" TabIndex="1"/>
</Grid>
</StackPanel>
<StackPanel Orientation="Vertical">
<TextBlock Text="MyTree"/>
<TreeView x:Name="MyTree" BorderThickness="0" Grid.IsSharedSizeScope="True" KeyboardNavigation.TabNavigation="Continue">
<TreeView.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent" />
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="Black" />
<SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightBrushKey}" Color="Transparent" />
<SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightTextBrushKey}" Color="Black" />
</TreeView.Resources>
<TreeView.ItemContainerStyle>
<Style TargetType="{x:Type TreeViewItem}">
<Setter Property="IsExpanded" Value="True" />
<Setter Property="KeyboardNavigation.TabNavigation" Value="Continue"/>
</Style>
</TreeView.ItemContainerStyle>
<TreeViewItem>
<TreeViewItem.Header>
<TextBlock Text="First Block" FontWeight="Bold"/>
</TreeViewItem.Header>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" SharedSizeGroup="Column1"/>
<ColumnDefinition Width="5" SharedSizeGroup="Column2"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="28"/>
<RowDefinition Height="28"/>
<RowDefinition Height="28"/>
<RowDefinition Height="28"/>
</Grid.RowDefinitions>
<GridSplitter Grid.Column="1" Grid.RowSpan="4" Width="5" HorizontalAlignment="Left" VerticalContentAlignment="Stretch" IsTabStop="False"/>
<TextBlock Grid.Row="0" Grid.Column="0" Text="A"/>
<CheckBox Grid.Row="0" Grid.Column="2" IsChecked="{Binding A}"/>
<TextBlock Grid.Row="1" Grid.Column="0" Text="B"/>
<TextBox Grid.Row="1" Grid.Column="2" Text="{Binding B}" Width="200"/>
<TextBlock Name="PassBin" Grid.Row="2" Grid.Column="0" Text="C"/>
<ComboBox x:Name="CbxPassBin" Grid.Row="2" Grid.Column="2" ItemsSource="{Binding C}" SelectedValue="{Binding SelectedC}"/>
</Grid>
</TreeViewItem>
</TreeView>
</StackPanel>
</StackPanel>
TabIndex should be 1 and Focusable="true"
I found a solution, at least for my specific situation. The error was the ItemContainerStyle definition in the TreeView. Define the Window/UserControl resource's style for the TreeViewItem as below:
<Style TargetType="TreeViewItem">
<Setter Property="KeyboardNavigation.TabNavigation" Value="Continue"/>
<Setter Property="IsTabStop" Value="False"/>
</Style>

Font size not setup for text

this below is a chat window. the font size is not setup where to put this? for the chat text we do have font size for the send button
MinHeight="550" MinWidth="834"
Closed="Window_Closed" >
<Window.Resources>
<Style x:Key="SpeechOptionsStyle" TargetType="RadioButton">
<Setter Property="Margin" Value="2,8,0,0" />
</Style>
<Style x:Key="ChatButtonStyle" TargetType="Button">
<Setter Property="Background" Value="Transparent" />
<Setter Property="Height" Value="23" />
<Setter Property="VerticalAlignment" Value="Top" />
<Setter Property="HorizontalAlignment" Value="Right" />
<Setter Property="Width" Value="150" />
<Setter Property="Margin" Value="0,5,0,0" />
</Style>
</Window.Resources>
<Grid>
<Grid.Background>
<LinearGradientBrush>
<GradientStop Color="LightSlateGray" Offset="0"/>
<GradientStop Color="Gainsboro" Offset="0.7"/>
<GradientStop Color="LightSlateGray" Offset="0.95"/>
</LinearGradientBrush>
</Grid.Background>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="170" />
</Grid.ColumnDefinitions>
<ListBox Grid.Row="1" Grid.Column="0" x:Name="chatListBoxMsgs" Margin="10"
HorizontalContentAlignment="Stretch" >
<ListBox.ItemContainerStyle>
<Style TargetType="{x:Type ListBoxItem}" >
<EventSetter Event="MouseDoubleClick"
Handler="chatListBoxMsgs_MouseDoubleClick" />
</Style>
</ListBox.ItemContainerStyle>
</ListBox>
<Grid Grid.Row="1" Grid.Column="1" HorizontalAlignment="Right" Margin="10"
Width="150">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<ListBox Grid.Row="0" x:Name="chatListBoxNames" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="150" />
<StackPanel Grid.Row="1" Margin="0,10,0,0"> <CheckBox Visibility="Hidden" x:Name="chatCheckBoxWhisper" Height="17" HorizontalAlignment="Left" Foreground="Black" FontSize="12" >Whisper Mode</CheckBox>
</StackPanel>
</Grid>
<TextBlock Visibility="Visible" Grid.Row="2" Grid.Column="0" x:Name="chatLabelWritingMsg"
Height="45" VerticalAlignment="Top" Foreground="MediumBlue"
TextWrapping="Wrap" Margin="10,0,0,0">Status</TextBlock>
<StackPanel Grid.Row="2" Grid.Column="1" Grid.RowSpan="2"
Orientation="Vertical" Margin="10,0" >
<Button x:Name="chatButtonConnect" Click="chatButtonConnect_Click"
Style="{StaticResource ChatButtonStyle}" >Connect</Button>
<Button x:Name="chatButtonDisconnect" Click="chatButtonDisconnect_Click"
Style="{StaticResource ChatButtonStyle}" >Disconnect</Button>
</StackPanel>
<Grid Grid.Row="3" Grid.Column="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBox Grid.Column="0" x:Name="chatTxtBoxType" Height="60"
VerticalAlignment="Top" Margin="10,0,5,5" TextWrapping="Wrap"
SpellCheck.IsEnabled="True" />
<Button Grid.Column="1" x:Name="chatButtonSend"
Click="chatButtonSend_Click" Height="60" VerticalAlignment="Top"
HorizontalAlignment="Right" Width="50" Margin="5,0,5,5"
FontSize="14">Send</Button>
</Grid>
</Grid>
</Window>
we have here the fontsize for the send button where do we put font ssize for the chat text it is defaulting to 8
From your code I think you want to set the font size of chatTxtBoxType. You can do it right in there (using an example size of 14):
<TextBox Grid.Column="0" x:Name="chatTxtBoxType" Height="60"
VerticalAlignment="Top" Margin="10,0,5,5" TextWrapping="Wrap"
SpellCheck.IsEnabled="True" FontSize="14"/>
Or using a style, like how you did for buttons (in that case, you might want to move some other properties to the style):
<Window.Resources>
<Style x:Key="ChatBoxStyle" TargetType="TextBox">
<Setter Property="FontSize" Value="14" />
</Style>
...
<TextBox Grid.Column="0" x:Name="chatTxtBoxType" Height="60"
VerticalAlignment="Top" Margin="10,0,5,5" TextWrapping="Wrap"
SpellCheck.IsEnabled="True" Style="{StaticResource ChatBoxStyle}"/>

Creating two identical looking TabItems but with different bindings

I'm workin on a program, which offers a easy to use interface to edit config-files. The config-files contain two sections which are loadeded into two different lists.
Now the two lists should visually appear the same(like above), without replicating the code if possible, so that I dont have the same code twice and only the binding differs. I'm working with the MVVM-Pattern and thats the XAML-Code for the TabItem:
<TabItem Header="Windows">
<Grid Background="#FFE5E5E5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="10"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="100"/>
<ColumnDefinition Width="10"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="10"/>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="30"/>
<RowDefinition Height="10"/>
</Grid.RowDefinitions>
<Label Grid.Row="1" Grid.Column="1" Content="Kreditoren Software"/>
<Label Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2" Margin="135,0,0,0" HorizontalAlignment="Right">
<Label.Content>
<Binding Path="CfgVersion"/>
</Label.Content>
<Label.ContentStringFormat>
File-Version: {0}
</Label.ContentStringFormat>
</Label>
<Border Background="{StaticResource BrushC1}" BorderThickness="1" BorderBrush="{StaticResource BrushC6}"
HorizontalAlignment="Stretch" Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="2" >
<Grid HorizontalAlignment="Stretch">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<ContentControl
Grid.Column="0"
Content=""
Foreground="{StaticResource BrushC7}"
Effect="{StaticResource ShadowS11}"
Margin="0"
Style="{StaticResource ico_search}"
Height="{StaticResource IconHeight}"
Width="{StaticResource IconWidth}"
VerticalAlignment="Center"
HorizontalAlignment="Left"
IsTabStop="False"
TabIndex="-1"/>
<TextBox Grid.Column="1" Height="20" Width="Auto" Text="{Binding FilterText, UpdateSourceTrigger=PropertyChanged}" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" BorderThickness="0" Margin="0,4" GotFocus="TextBox_GotFocus"/>
</Grid>
</Border>
<ListView x:Name="Kred_ListView" Grid.Row="3" Grid.Column="1" Grid.ColumnSpan="2" Margin="0,5" ItemsSource="{Binding Kreditoren, Mode=OneWay}" SelectedItem="{Binding SelectedKreditor, Mode=TwoWay}" MouseLeftButtonDown="MouseClick">
<ListView.ItemContainerStyle>
<Style TargetType="{x:Type ListViewItem}">
<Setter Property="behavior:ListViewBehavior.IsBroughtIntoViewWhenSelected" Value="true"/>
<Style.Triggers>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.IsListEditable}" Value="True"/>
<Condition Binding="{Binding RelativeSource={RelativeSource Mode=Self}, Path=IsSelected}" Value="true"/>
</MultiDataTrigger.Conditions>
<Setter Property="behavior:ListViewBehavior.IsBroughtIntoViewWhenSelected" Value="true"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="30"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock>
<Hyperlink Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.RemoveKreditorCommand}">
<Image Grid.Column="0" Height="20" Source="/S-Param;component/Resources/delete.png" Margin="5,0"/>
</Hyperlink>
</TextBlock>
<Border Grid.Column="1" BorderThickness="1" BorderBrush="Black">
<TextBox Height="18" Text="{Binding Name, Mode=TwoWay}" HorizontalAlignment="Stretch" VerticalAlignment="Center"/>
</Border>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="Margin" Value="0,5"/>
</MultiDataTrigger>
</Style.Triggers>
</Style>
</ListView.ItemContainerStyle>
</ListView>
<Button Grid.Row="4" Grid.Column="1" Content="Bearbeiten" Visibility="{Binding IsEditButtonVisible}" Margin="100,0,10,0" Command="{Binding EditCommand}"/>
<Button Grid.Row="4" Grid.Column="2" Content="Speichern" Visibility="{Binding IsEditButtonVisible}" Margin="0" Command="{Binding SaveCommand}"/>
<Button Grid.Row="4" Grid.Column="2" Content="Übernehmen" Visibility="{Binding IsSaveListButtonVisible}" Margin="0" Command="{Binding SaveListCommand}"/>
<Button Grid.Row="4" Grid.Column="1" Content="Neu..." Visibility="{Binding IsSaveListButtonVisible}" Margin="100,0,10,0" Command="{Binding AddKreditorCommand}"/>
</Grid>
</TabItem>
If further Information is required I'll try to append them.
If there are grammar or spelling errors, feel free to correct them.

Categories

Resources