如何在扩展Telerik RadTileViewItem的自定义控件的标题中添加按钮
本文关键字:自定义控件 标题 添加 按钮 RadTileViewItem 扩展 Telerik | 更新日期: 2023-09-27 17:59:16
这是我的自定义控件,它扩展了Telerik RadTileViewItem控件:
<telerik:RadTileViewItem x:Class="CrmActivityTimer.Customcontrols.TimerTile"
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"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
DataContext="{Binding RelativeSource={RelativeSource Self}}"
mc:Ignorable="d" Height="525" Width="375" TileStateChanged="TimerTile_OnTileStateChanged">
<telerik:RadTileViewItem.Resources>
<Style x:Key="TimerTileHeaderStyle">
</Style>
</telerik:RadTileViewItem.Resources>
<Grid>
<TextBox Text="{Binding Timer.TimeElapsed}" Width="100px" Height="20px" Margin="102,17,155,437" IsReadOnly="True"/>
<Button Height="20px" Width="20px" Margin="216,17,121,437" Click="PlayButton_OnClick">
<Image Source="icons/Play.png" />
</Button>
<Button Height="20px" Width="20px" Margin="242,17,95,437" Click="PauseButton_OnClick">
<Image Source="icons/Pause.png" />
</Button>
<telerik:RadComboBox Name="CboKlant" HorizontalAlignment="Left" Margin="101,79,0,0" VerticalAlignment="Top" Width="230"
ItemsSource="{Binding Fields.Accounts}" DisplayMemberPath="Name" SelectedValuePath="AccountId" KeyboardNavigation.TabIndex="1"/>
<telerik:RadComboBox Name="CboBetreft" HorizontalAlignment="Left" Margin="101,160,0,0" VerticalAlignment="Top" Width="230" KeyboardNavigation.TabIndex="4"
DisplayMemberPath="{Binding Fields.BetreftNameField}" SelectedValuePath="{Binding Fields.BetreftIdField}"/>
<TextBox Name="TxtOnderwerp" HorizontalAlignment="Left" Height="23" Margin="102,50,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="230" KeyboardNavigation.TabIndex="0"/>
<Label Content="Onderwerp" HorizontalAlignment="Left" Margin="10,50,0,0" VerticalAlignment="Top" Height="23" Width="87" Padding="0"/>
<Label Content="Klant" HorizontalAlignment="Left" Margin="9,78,0,0" VerticalAlignment="Top" Height="23" Width="87" Padding="0"/>
<Label Content="Betreft" HorizontalAlignment="Left" Margin="9,159,0,0" VerticalAlignment="Top" Height="23" Width="87" Padding="0"/>
<telerik:RadComboBox x:Name="CboUser" HorizontalAlignment="Left" Margin="101,188,0,0" VerticalAlignment="Top" Width="230" KeyboardNavigation.TabIndex="5"
ItemsSource="{Binding Fields.Users}" DisplayMemberPath="FullName" SelectedValuePath="SystemUserId" SelectedValue="{Binding Fields.Currentuser}" />
<Label Content="Gebruiker" HorizontalAlignment="Left" Margin="9,187,0,0" VerticalAlignment="Top" Height="23" Width="87" Padding="0"/>
<telerik:RadComboBox x:Name="CboService" HorizontalAlignment="Left" Margin="101,216,0,0" VerticalAlignment="Top" Width="230" KeyboardNavigation.TabIndex="6"
ItemsSource="{Binding Fields.Services}" DisplayMemberPath="Name" SelectedValuePath="ServiceId"/>
<Label Content="Service" HorizontalAlignment="Left" Margin="9,215,0,0" VerticalAlignment="Top" Height="23" Width="87" Padding="0"/>
<Button HorizontalAlignment="Left" Height="35" Margin="296,10,0,0" VerticalAlignment="Top" Width="35" Click="BtnCreateActivity_OnClick">
<Image Source="icons/Save.png" Width="35"/>
</Button>
<telerik:RadComboBox HorizontalAlignment="Left" Margin="101,106,0,0" VerticalAlignment="Top" Width="230" SelectionChanged="CboKoppelingsType_OnSelectionChanged" KeyboardNavigation.TabIndex="2">
<telerik:RadComboBoxItem Content="Verkoopkans"/>
<telerik:RadComboBoxItem Content="Job"/>
<telerik:RadComboBoxItem Content="Ticket"/>
</telerik:RadComboBox>
<Label Content="Betreft is een..." HorizontalAlignment="Left" Margin="9,106,0,0" VerticalAlignment="Top" Width="87" Height="22" Padding="0"/>
<Label Content="Project" HorizontalAlignment="Left" Margin="9,133,0,0" VerticalAlignment="Top" Width="88" Padding="0"/>
<telerik:RadComboBox Name="CboProject" HorizontalAlignment="Left" Margin="102,133,0,0" VerticalAlignment="Top" Width="229" KeyboardNavigation.TabIndex="3"
ItemsSource="{Binding Fields.Projects}" DisplayMemberPath="New_titel" SelectedValuePath="New_ProjectId" SelectionChanged="CboProject_SelectionChanged" />
<TextBox Name="TxtVoorKlant" HorizontalAlignment="Left" Height="166" Margin="9,282,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="147"/>
<TextBox Name="TxtVoorIntern" HorizontalAlignment="Left" Height="166" Margin="176,282,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="155"/>
<Label Content="Voor de klant" HorizontalAlignment="Left" Margin="9,251,0,0" VerticalAlignment="Top" Width="87" Padding="0"/>
<Label Content="Intern" HorizontalAlignment="Left" Margin="170,251,0,0" VerticalAlignment="Top" Width="87" Padding="0"/>
</Grid>
我正试图在标题中向该控件添加一个按钮,以从TileView中删除该控件的实例。然而,关于这个问题的每一个教程都涉及到一个带有自定义标题的默认RadTileViewItem。我想修改RadTileViewItem的扩展上的标头。我试过在上使用示例代码http://www.telerik.com/forums/customize-radtileview,http://www.telerik.com/forums/header-template和其他控件,但我最终要么使用所有控件都已就位但没有自定义标头的TimerFile控件,要么使用自定义标头但没有其他控件的Timerile控件。
有人知道我该怎么做吗?我已经尝试过将所有控件移动到模板本身,但我不知道如何做到这一点,我确信这应该是可能的,不会有太多问题。
在WPF中更改控件外观的常用方法是为其提供一个新的ControlTemplate
,它定义了组成所需外观的控件。然而,为了做到这一点,您需要从Telerik中找到默认的RadTileViewItem ControlTemplate
XAML,并用它启动您的自定义ControlTemplate
。
如果您知道如何编写XAML,那么就不难找到默认ControlTemplate
的每个部分的作用以及在哪里添加Button
。有关详细信息,请阅读MSDN上的Control Authoring Overview页面。