目标:
当您单击箭头图片时,您应该执行特定的C#代码。箭头需要有点击模式或类似。
问题:
我不知道怎么做才能让这些箭头图片充当点击模式。
xaml代码:
<UserControl x:Class="usercontrol_bokning.UserControl1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid Background="White" Margin="-127,0,-777,-316">
<ListView x:Name="lvw_aktivitet" HorizontalAlignment="Left" ItemsSource="{Binding}" SelectionMode="Single" Height="337" Margin="217,147,0,0" VerticalAlignment="Top" Width="356" SelectionChanged="lvw_aktivitet_SelectionChanged">
<ListView.View>
<GridView>
<GridViewColumn Header="Tid" Width="auto" DisplayMemberBinding="{Binding Path=Tid}" TextBlock.TextAlignment="Left" />
<GridViewColumn Header="Aktivitet" Width="auto" DisplayMemberBinding="{Binding Path=Aktivitet}" TextBlock.TextAlignment="Left" />
<GridViewColumn Header="Total platser" Width="auto" DisplayMemberBinding="{Binding Path=Total_platser}" TextBlock.TextAlignment="Center" />
<GridViewColumn Header="Bokade" Width="auto" DisplayMemberBinding="{Binding Path=Bokade}" TextBlock.TextAlignment="Center" />
<GridViewColumn Header="Drop in" Width="auto" >
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock TextAlignment="Right" Block.TextAlignment="Right" Text="{Binding Path=Drop_in}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
<Calendar x:Name="cdate_left" HorizontalAlignment="Left" Margin="10,147,0,0" VerticalAlignment="Top" SelectedDatesChanged="cdate_left_SelectedDatesChanged"/>
<Button x:Name="btn_idag" Content="Idag" HorizontalAlignment="Left" Margin="217,122,0,0" VerticalAlignment="Top" Width="75" Click="btn_idag_Click"/>
<TabControl HorizontalAlignment="Left" Height="420" Margin="603,75,0,0" VerticalAlignment="Top" Width="589">
<TabItem Header="Bokade">
<Grid Background="#FFE5E5E5">
<ListView x:Name="lvw_bokade" HorizontalAlignment="Left" Height="335" Margin="10,46,0,0" VerticalAlignment="Top" Width="561">
<ListView.View>
<GridView>
<GridViewColumn/>
</GridView>
</ListView.View>
</ListView>
<Button Content="Ny plats" HorizontalAlignment="Left" Margin="10,21,0,0" VerticalAlignment="Top" Width="75"/>
</Grid>
</TabItem>
<TabItem Header="Avbokade">
<Grid Background="#FFE5E5E5" Margin="0,1,0,-1"/>
</TabItem>
</TabControl>
<Label x:Name="lbl_instruktor" Content="Instruktör: " HorizontalAlignment="Left" Margin="1009,122,0,0" VerticalAlignment="Top"/>
<Image x:Name="bild_arrow_left" HorizontalAlignment="Left" Height="22" Margin="302,121,0,0" VerticalAlignment="Top" Width="22" Source="C:\Users\Administrator\Downloads\left.jpg" />
<Image x:Name="bild_arrow_right" HorizontalAlignment="Left" Height="22" Margin="326,121,0,0" VerticalAlignment="Top" Width="22" Source="C:\Users\Administrator\Downloads\right.jpg"/>
<Label x:Name="lbl_DisplayDateBySelection" Content="" HorizontalAlignment="Left" Margin="396,119,0,0" VerticalAlignment="Top"/>
</Grid>
答案 0 :(得分:0)
如果您希望能够像Image
那样点击Button
,那么就可以使用Button
,只需将其Template
更改为{{1} }}。这样,您拥有Image
的所有功能,其外观为Button
Image
您可以绑定<Button>
<Button.Template>
<ControlTemplate TargetType="{x:Type Button}">
<Image Source="..."/>
</ControlTemplate>
</Button.Template>
</Button>
或添加Button.Command
事件处理程序