这是我的自定义控件,它扩展了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和其他方面使用示例代码,但我最终得到了我的TimerTile控件,所有控件都已就位但没有自定义标头或带有自定义标头的TimerTile控件到位,但没有其他控制。
有谁知道我怎么做到这一点?我已经尝试将所有控件移动到模板本身,但我无法弄清楚如何做到这一点,我很确定它应该可以没有太多问题。
答案 0 :(得分:1)
在WPF中更改控件外观的常用方法是为它提供一个新的ControlTemplate
,它定义构成所需外观的控件。但是,为了做到这一点,您需要找到Telerik的默认RadTileViewItem ControlTemplate
XAML,然后用它启动自定义ControlTemplate
。
如果您知道如何编写XAML,那么找不到默认ControlTemplate
的每个部分以及添加Button
的位置都不难。请阅读MSDN上的Control Authoring Overview页面以获取更多信息。