Telerik Forums
UI for WPF Forum
1 answer
386 views
Hi !

We try to make an autocompletebox where some of the items could be disabled individually.

We first try to make a BoxesItemTemplate but the item’s “little cross” which delete the selected items from the list where not in there.

So we decided to make a Style/template for the complete “autocompletebox”.
In this style we define the item container style in order not to have the "little cross":

<telerik1:AutoCompleteBoxesItemsControl.ItemContainerStyle>
  <Style TargetType="{x:Type telerik1:RadAutoCompleteBoxItem}">
     <Setter Property="Template">
         <Setter.Value>
            <ControlTemplate TargetType="{x:Type telerik1:RadAutoCompleteBoxItem}">
                <Border CornerRadius="1" x:Name="Bd" SnapsToDevicePixels="true" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding                         BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}">
                   <StackPanel Orientation="Horizontal">
                     <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding                       VerticalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                                                                 
                    </StackPanel>
                </Border>
           </ControlTemplate>
        </Setter.Value>
    </Setter>
  </Style>
</telerik1:AutoCompleteBoxesItemsControl.ItemContainerStyle>
And we did a BoxesItemTemplate in which we put a button for the "little cross" that should delete the item when pressed. But then we were enabled to bind to the delete command (the command that delete the item).
On our button we try some things like :
Command="telerik:RadAutoCompleteBoxCommands.RemoveItem"
But it does not work. I suppose we do not give the write arguments (perhaps the "item" as parametter)

Do you have any solution?

FOR INFORMATION:
The AutoCompleteBox object:
<telerik1:RadAutoCompleteBox Grid.Row="0"
                                    x:Name="RadAutoCompleteBox" Height="30" Margin="5"
                                    TextSearchPath="SearchString"
                                    TextSearchMode="Contains"
                                    AutoCompleteMode="Suggest"
                                    DropDownItemTemplate="{StaticResource CustomDropDownItemTemplate}"
                                    SearchTextChanged="RadAutoCompleteBox_OnSearchTextChanged" Style="{DynamicResource RadAutoCompleteBoxGinkgoStyle}"
                                    >
 
            <telerik1:RadAutoCompleteBox.BoxesItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="{Binding DisplayString}"/>
                        <Button Width="10" Height="10" Margin="3,0,0,0" Click="Button_Click"  Cursor="Arrow">
                            <Button.Template>
                                <ControlTemplate>
                                    <Grid>
                                        <Rectangle Stroke="Black"  />
                                        <Path Data="M0,0 L100,100" Margin="2,2,2,2" Stretch="Fill" Stroke="Black"/>
                                        <Path Data="M100,0 L0,100" Margin="2,2,2,2" Stretch="Fill" Stroke="Black" />
                                    </Grid>
                                </ControlTemplate>
                            </Button.Template>
                        </Button>
                    </StackPanel>
                </DataTemplate>
           </telerik1:RadAutoCompleteBox.BoxesItemTemplate>
       </telerik1:RadAutoCompleteBox>



The complete style/template:

<Style x:Key="RadAutoCompleteBoxGinkgoStyle" TargetType="{x:Type telerik1:RadAutoCompleteBox}">
           <Setter Property="IsTabStop" Value="False"/>
           <Setter Property="TextBoxStyle">
               <Setter.Value>
                   <Style TargetType="{x:Type telerik1:RadWatermarkTextBox}">
                       <Setter Property="BorderThickness" Value="0"/>
                       <Setter Property="Margin" Value="3,3,0,0"/>
                       <Setter Property="Padding" Value="0"/>
                       <Setter Property="BorderBrush" Value="Transparent"/>
                       <Setter Property="Background" Value="Transparent"/>
                       <Setter Property="Template">
                           <Setter.Value>
                               <ControlTemplate TargetType="{x:Type telerik1:RadWatermarkTextBox}">
                                   <Grid x:Name="RootElement" Cursor="IBeam">
                                       <VisualStateManager.VisualStateGroups>
                                           <VisualStateGroup x:Name="CommonStates">
                                               <VisualState x:Name="Normal">
                                                   <Storyboard>
                                                       <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="MouseOverVisual">
                                                           <LinearDoubleKeyFrame KeyTime="0:0:0.15" Value="0"/>
                                                       </DoubleAnimationUsingKeyFrames>
                                                       <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="MouseOverVisual">
                                                           <DiscreteObjectKeyFrame KeyTime="0:0:0.15">
                                                               <DiscreteObjectKeyFrame.Value>
                                                                   <Visibility>Collapsed</Visibility>
                                                               </DiscreteObjectKeyFrame.Value>
                                                           </DiscreteObjectKeyFrame>
                                                       </ObjectAnimationUsingKeyFrames>
                                                   </Storyboard>
                                               </VisualState>
                                               <VisualState x:Name="MouseOver">
                                                   <Storyboard>
                                                       <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="MouseOverVisual">
                                                           <LinearDoubleKeyFrame KeyTime="0:0:0.115" Value="1"/>
                                                       </DoubleAnimationUsingKeyFrames>
                                                       <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="MouseOverVisual">
                                                           <DiscreteObjectKeyFrame KeyTime="0">
                                                               <DiscreteObjectKeyFrame.Value>
                                                                   <Visibility>Visible</Visibility>
                                                               </DiscreteObjectKeyFrame.Value>
                                                           </DiscreteObjectKeyFrame>
                                                       </ObjectAnimationUsingKeyFrames>
                                                   </Storyboard>
                                               </VisualState>
                                               <VisualState x:Name="Disabled">
                                                   <Storyboard>
                                                       <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="DisabledVisualElement"/>
                                                       <DoubleAnimation Duration="0" To="0.6" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="PART_ContentHost"/>
                                                   </Storyboard>
                                               </VisualState>
                                           </VisualStateGroup>
                                           <VisualStateGroup x:Name="WatermarkStates">
                                               <VisualState x:Name="WatermarkHidden">
                                                   <Storyboard>
                                                       <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="WatermarkVisualElement"/>
                                                   </Storyboard>
                                               </VisualState>
                                               <VisualState x:Name="WatermarkVisible"/>
                                           </VisualStateGroup>
                                       </VisualStateManager.VisualStateGroups>
                                       <Border x:Name="Border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Opacity="1"/>
                                       <Border x:Name="MouseOverVisual" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Grid.ColumnSpan="2" IsHitTestVisible="False" Opacity="0" Grid.RowSpan="2" Visibility="Collapsed"/>
                                       <Border x:Name="DisabledVisualElement" BorderBrush="#FF989898" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" IsHitTestVisible="False" Opacity="0"/>
                                       <ScrollViewer x:Name="PART_ContentHost" BorderThickness="0" IsTabStop="False" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
                                           <telerik1:StyleManager.Theme>
                                               <telerik1:Office_BlackTheme/>
                                           </telerik1:StyleManager.Theme>
                                       </ScrollViewer>
                                       <Border x:Name="FocusVisual" BorderBrush="#FFFFC92B" BorderThickness="{TemplateBinding BorderThickness}" Grid.ColumnSpan="2" CornerRadius="1" IsHitTestVisible="False" Opacity="0" Grid.RowSpan="2">
                                           <Border BorderBrush="Transparent" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="0"/>
                                       </Border>
                                       <ContentControl x:Name="WatermarkVisualElement" BorderThickness="{TemplateBinding BorderThickness}" ContentTemplate="{TemplateBinding WatermarkTemplate}" Content="{TemplateBinding WatermarkContent}" FontStyle="Italic" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" IsHitTestVisible="False" IsTabStop="False" Margin="{TemplateBinding Padding}" Opacity="0.5" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                                   </Grid>
                               </ControlTemplate>
                           </Setter.Value>
                       </Setter>
                       <Style.BasedOn>
                           <Style TargetType="{x:Type telerik1:RadWatermarkTextBox}">
                               <Setter Property="Foreground" Value="Black"/>
                               <Setter Property="Padding" Value="5,3"/>
                               <Setter Property="VerticalContentAlignment" Value="Center"/>
                               <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
                               <Setter Property="AllowDrop" Value="True"/>
                               <Setter Property="IsTabStop" Value="True"/>
                               <Setter Property="BorderBrush" Value="#FF848484"/>
                               <Setter Property="Background" Value="White"/>
                               <Setter Property="BorderThickness" Value="1"/>
                               <Setter Property="KeyboardNavigation.TabNavigation" Value="Once"/>
                               <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
                               <Setter Property="SnapsToDevicePixels" Value="True"/>
                               <Setter Property="Template">
                                   <Setter.Value>
                                       <ControlTemplate TargetType="{x:Type telerik1:RadWatermarkTextBox}">
                                           <Grid x:Name="RootElement" Cursor="IBeam">
                                               <VisualStateManager.VisualStateGroups>
                                                   <VisualStateGroup x:Name="CommonStates">
                                                       <VisualState x:Name="Normal">
                                                           <Storyboard>
                                                               <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="MouseOverVisual">
                                                                   <LinearDoubleKeyFrame KeyTime="0:0:0.15" Value="0"/>
                                                               </DoubleAnimationUsingKeyFrames>
                                                               <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="MouseOverVisual">
                                                                   <DiscreteObjectKeyFrame KeyTime="0:0:0.15">
                                                                       <DiscreteObjectKeyFrame.Value>
                                                                           <Visibility>Collapsed</Visibility>
                                                                       </DiscreteObjectKeyFrame.Value>
                                                                   </DiscreteObjectKeyFrame>
                                                               </ObjectAnimationUsingKeyFrames>
                                                           </Storyboard>
                                                       </VisualState>
                                                       <VisualState x:Name="MouseOver">
                                                           <Storyboard>
                                                               <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="MouseOverVisual">
                                                                   <LinearDoubleKeyFrame KeyTime="0:0:0.115" Value="1"/>
                                                               </DoubleAnimationUsingKeyFrames>
                                                               <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="MouseOverVisual">
                                                                   <DiscreteObjectKeyFrame KeyTime="0">
                                                                       <DiscreteObjectKeyFrame.Value>
                                                                           <Visibility>Visible</Visibility>
                                                                       </DiscreteObjectKeyFrame.Value>
                                                                   </DiscreteObjectKeyFrame>
                                                               </ObjectAnimationUsingKeyFrames>
                                                           </Storyboard>
                                                       </VisualState>
                                                       <VisualState x:Name="Disabled">
                                                           <Storyboard>
                                                               <DoubleAnimation Duration="0" To="0.6" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="DisabledVisualElement"/>
                                                               <DoubleAnimation Duration="0" To="0.6" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="PART_ContentHost"/>
                                                           </Storyboard>
                                                       </VisualState>
                                                       <VisualState x:Name="ReadOnly">
                                                           <Storyboard>
                                                               <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="ReadOnlyVisualElement"/>
                                                           </Storyboard>
                                                       </VisualState>
                                                   </VisualStateGroup>
                                                   <VisualStateGroup x:Name="FocusStates">
                                                       <VisualState x:Name="Focused">
                                                           <Storyboard>
                                                               <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="FocusVisual"/>
                                                           </Storyboard>
                                                       </VisualState>
                                                       <VisualState x:Name="Unfocused"/>
                                                   </VisualStateGroup>
                                                   <VisualStateGroup x:Name="WatermarkStates">
                                                       <VisualState x:Name="WatermarkHidden">
                                                           <Storyboard>
                                                               <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="WatermarkVisualElement"/>
                                                           </Storyboard>
                                                       </VisualState>
                                                       <VisualState x:Name="WatermarkVisible"/>
                                                   </VisualStateGroup>
                                               </VisualStateManager.VisualStateGroups>
                                               <Border x:Name="Border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" CornerRadius="1" Opacity="1"/>
                                               <Border x:Name="ReadOnlyVisualElement" Background="#5EC9C9C9" CornerRadius="1" Opacity="0"/>
                                               <Border x:Name="MouseOverVisual" BorderBrush="#FFFFC92B" BorderThickness="{TemplateBinding BorderThickness}" Grid.ColumnSpan="2" CornerRadius="1" IsHitTestVisible="False" Opacity="0" Grid.RowSpan="2" Visibility="Collapsed"/>
                                               <Border x:Name="DisabledVisualElement" BorderBrush="#FF989898" BorderThickness="{TemplateBinding BorderThickness}" Background="#FFE0E0E0" CornerRadius="1" IsHitTestVisible="False" Opacity="0"/>
                                               <ScrollViewer x:Name="PART_ContentHost" BorderThickness="0" Cursor="Arrow" IsTabStop="False" Margin="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
                                                   <telerik1:StyleManager.Theme>
                                                       <telerik1:Office_BlackTheme/>
                                                   </telerik1:StyleManager.Theme>
                                               </ScrollViewer>
                                               <Border x:Name="FocusVisual" BorderBrush="#FFFFC92B" BorderThickness="{TemplateBinding BorderThickness}" Grid.ColumnSpan="2" CornerRadius="1" IsHitTestVisible="False" Opacity="0" Grid.RowSpan="2">
                                                   <Border BorderBrush="Transparent" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="0"/>
                                               </Border>
                                               <ContentControl x:Name="WatermarkVisualElement" BorderThickness="{TemplateBinding BorderThickness}" ContentTemplate="{TemplateBinding WatermarkTemplate}" Content="{TemplateBinding WatermarkContent}" Foreground="{TemplateBinding Foreground}" FontStyle="Italic" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" IsHitTestVisible="False" IsTabStop="False" Margin="2,0,0,0" Opacity="0.5" Padding="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
                                                   <ContentControl.Template>
                                                       <ControlTemplate TargetType="{x:Type ContentControl}">
                                                           <Border BorderThickness="{TemplateBinding BorderThickness}">
                                                               <ContentPresenter ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" ContentStringFormat="{TemplateBinding ContentStringFormat}" Margin="{TemplateBinding Padding}"/>
                                                           </Border>
                                                       </ControlTemplate>
                                                   </ContentControl.Template>
                                               </ContentControl>
                                           </Grid>
                                       </ControlTemplate>
                                   </Setter.Value>
                               </Setter>
                           </Style>
                       </Style.BasedOn>
                   </Style>
               </Setter.Value>
           </Setter>
           <Setter Property="Template">
               <Setter.Value>
                   <ControlTemplate TargetType="{x:Type telerik1:RadAutoCompleteBox}">
                       <Grid>
                           <VisualStateManager.VisualStateGroups>
                               <VisualStateGroup x:Name="CommonStates">
                                   <VisualState x:Name="Normal"/>
                                   <VisualState x:Name="MouseOver">
                                       <Storyboard>
                                           <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="MouseOverVisual"/>
                                       </Storyboard>
                                   </VisualState>
                                   <VisualState x:Name="Disabled">
                                       <Storyboard>
                                           <DoubleAnimation Duration="0" To="0.6" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="DisabledVisualElement"/>
                                       </Storyboard>
                                   </VisualState>
                               </VisualStateGroup>
                               <VisualStateGroup x:Name="FocusStates">
                                   <VisualState x:Name="Unfocused"/>
                                   <VisualState x:Name="Focused">
                                       <Storyboard>
                                           <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="FocusVisual"/>
                                       </Storyboard>
                                   </VisualState>
                               </VisualStateGroup>
                           </VisualStateManager.VisualStateGroups>
                           <Border x:Name="Border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" CornerRadius="1"/>
                           <Border x:Name="MouseOverVisual" BorderBrush="#FFFFC92B" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="1" Opacity="0"/>
                           <Border x:Name="FocusVisual" BorderBrush="#FFFFC92B" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" CornerRadius="1" IsHitTestVisible="False" Opacity="0">
                               <Border BorderBrush="Transparent" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="0"/>
                           </Border>
                           <Border x:Name="DisabledVisualElement" BorderBrush="#FF989898" BorderThickness="{TemplateBinding BorderThickness}" Background="#FFE0E0E0" CornerRadius="1" IsHitTestVisible="False" Opacity="0"/>
                           <ScrollViewer x:Name="PART_ScrollViewer" BorderThickness="0" Background="Transparent" Height="{TemplateBinding Height}" HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}" IsTabStop="False" Margin="{TemplateBinding BorderThickness}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
                               <telerik1:StyleManager.Theme>
                                   <telerik1:Office_BlackTheme/>
                               </telerik1:StyleManager.Theme>
                               <telerik1:AutoCompleteBoxesItemsControl x:Name="PART_Boxes"
                                                                      BoxesItemTemplate="{TemplateBinding BoxesItemTemplate}"
                                                                      DisplayMemberPath="{TemplateBinding DisplayMemberPath}"
                                                                      Foreground="{TemplateBinding Foreground}"
                                                                      Height="{TemplateBinding Height}"
                                                                      ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                                                                      IsTabStop="False"
                                                                      Margin="{TemplateBinding Padding}"
                                                                      ScrollViewer.VerticalScrollBarVisibility="Disabled" >
                                   <telerik1:AutoCompleteBoxesItemsControl.ItemsPanel>
                                       <ItemsPanelTemplate>
                                           <telerik1:AutoCompleteBoxesWrapPanel IsItemsHost="True" Width="{Binding ActualWidth, ElementName=WatermarkTextBox}"/>
                                       </ItemsPanelTemplate>
                                  </telerik1:AutoCompleteBoxesItemsControl.ItemsPanel>
 
                                   <telerik1:AutoCompleteBoxesItemsControl.ItemContainerStyle>
                                       <Style TargetType="{x:Type telerik1:RadAutoCompleteBoxItem}">
                                           <Setter Property="Template">
                                               <Setter.Value>
                                                   <ControlTemplate TargetType="{x:Type telerik1:RadAutoCompleteBoxItem}">
                                                       <Border CornerRadius="1" x:Name="Bd" SnapsToDevicePixels="true" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}">
                                                           <StackPanel Orientation="Horizontal">
                                                               <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                                                                
                                                           </StackPanel>
                                                            
                                                       </Border>
                                                   </ControlTemplate>
                                               </Setter.Value>
                                           </Setter>
                                       </Style>
                                  </telerik1:AutoCompleteBoxesItemsControl.ItemContainerStyle>
 
                              </telerik1:AutoCompleteBoxesItemsControl>
                           </ScrollViewer>
                           <Popup x:Name="PART_Popup">
                               <Grid x:Name="PopupRoot">
                                   <telerik1:RadListBox x:Name="PART_ListBox"
                                                        CanKeyboardNavigationSelectItems="{x:Null}"
                                                        IsTabStop="False"
                                                        ItemTemplate="{TemplateBinding DropDownItemTemplate}"
                                                        IsTextSearchEnabled="True"
                                                        MaxHeight="{TemplateBinding MaxDropDownHeight}"
                                                        MinWidth="{TemplateBinding MinDropDownWidth}"
                                                        SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                                        SelectedValueBinding="{x:Null}"
                                                        TextBinding="{x:Null}"
                                                        ItemsSource="{TemplateBinding FilteredItems}">
 
                                       <telerik1:StyleManager.Theme>
                                           <telerik1:Office_BlackTheme/>
                                       </telerik1:StyleManager.Theme>
                                   </telerik1:RadListBox>
                               </Grid>
                           </Popup>
                       </Grid>
                   </ControlTemplate>
               </Setter.Value>
           </Setter>
           <Setter Property="BorderBrush" Value="#FF848484"/>
           <Setter Property="BorderThickness" Value="1"/>
           <Setter Property="Background" Value="White"/>
           <Setter Property="Padding" Value="0,0,3,3"/>
           <Setter Property="Cursor" Value="IBeam"/>
           <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Disabled"/>
           <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled"/>
           <Setter Property="SnapsToDevicePixels" Value="True"/>
       </Style>

Vladi
Telerik team
 answered on 04 Jul 2013
1 answer
37 views
Hi All,
Can end-user add(modify) SpecialSlot?

Thanks

Yana
Telerik team
 answered on 04 Jul 2013
3 answers
108 views
Hello,

I have a RadRibbonButton and in it I set the LargeImage property. ie:
<RadRibbonButton LargeImage="pack://application:,,,/ESCCommon;component/Images/find32.png" />

(ESCCommon is ofcourse in a different project in the solution)

The program crashes saying it can not find this image file, yet elsewhere in the same project I have an image with source set to the same image and it finds it (ie this works):
<Button>
    <StackPanel>
       <Image Source="pack://application:,,,/ESCCommon;component/Images/find32.png" />
   </StackPanel>
</Button>

How do I get the LargeImage to display?

Thanks
Andrew
Top achievements
Rank 1
 answered on 04 Jul 2013
5 answers
219 views
Hi,
I'd like to know whether it's possible to focus filtering control in the first column. Our customer want to speed up searching, so he doesn't want to click on textbox to filter - he just want to start typing text from keyboard and gets result asap.
I tried to add event in the constructor:

productsDG.FieldFilterEditorCreated += new EventHandler<Telerik.Windows.Controls.GridView.EditorCreatedEventArgs>(productsDG_FieldFilterEditorCreated);

void productsDG_FieldFilterEditorCreated(object sender, Telerik.Windows.Controls.GridView.EditorCreatedEventArgs e)
{
    if (e.Column.Header.ToString() == "Nazwa")
        e.Editor.Focus();
}

but it seems it doesn't work.
Yoan
Telerik team
 answered on 03 Jul 2013
3 answers
303 views
I'm using a GridView and would like to show a focus indicator for the entire row rather than a single cell.  Here's a sample of what I've tried:

XAML:
<Window x:Class="RadGridViewRowFocus.MainWindow"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <telerik:RadGridView ItemsSource="{Binding Items}"
                             SelectionUnit="FullRow"
                             IsReadOnly="True" />
    </Grid>
</Window>

Code Behind:
namespace RadGridViewRowFocus
{
    using System.Collections.ObjectModel;
    using System.Windows;
 
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
 
            DataContext = this;
            Items = new ObservableCollection<SampleData>
            {
                new SampleData { Field1 = "Item 1", Field2 = "Item 1, Field 2" },
                new SampleData { Field1 = "Item 2", Field2 = "Item 2, Field 2" },
                new SampleData { Field1 = "Item 3", Field2 = "Item 3, Field 2" },
                new SampleData { Field1 = "Item 4", Field2 = "Item 4, Field 2" }
            };
        }
 
        public ObservableCollection<SampleData> Items { get; set; }
    }
 
    public class SampleData
    {
        public string Field1 { get; set; }
        public string Field2 { get; set; }
    }
}

I'd like to get a dotted-line focus indicator around the entire row (excluding the row header), similar to an item in a list box.  I would have thought setting SelectionUnit="FullRow" would cause that to happen, but I still see a focus rectangle around the cell that is focused.  If there's a different control that would provide this along with columns, then I'm open to that too.
Dimitrina
Telerik team
 answered on 03 Jul 2013
4 answers
175 views
I have a radmap in an application that displays a collection of POI's. Its put together using an information layer with a data template that defines what they will look like. Its all mvvm, so no code behind events at this point.

The problem that I am having is that the map needs to update - and this usually consists of a different set of points. I have already read and know how I can reload the center and the zoom in the map loaded event. The problem is that when the data is refreshed - the map is not reloaded - and I also do not have access to the RadMap control (found a solution where you can set the center and zoom if the RadMap is part of the event argument based on a code-behind loaded event).

Anways, what I am trying to find is a way to update the center and zoom on the map (using LocationRect) when the POI's change. And I need to accomplish this without using code-behind events. Is there another event that I can wire up to a command/event that will fire when the POI's are cleared and then re-rendered... maybe something in the InformationLayer?
Michael
Top achievements
Rank 1
 answered on 03 Jul 2013
3 answers
169 views

Hello Telerik, been while!

I am currently attempting to give my reporting screen a bit of 'wow' but have hit a snag...

The CarouselPanel is perfect for my needs - however it does not seem to incorporate the ability to bind MVVM loaded collections.
Will I have to re-code the entire Carousel control to make it similar to the CarouselPanel, or have I missed something?

btw; I want the item-wrapping and mouse-driven elements from the Panel type (hence the choice).
Maya
Telerik team
 answered on 03 Jul 2013
5 answers
588 views
Hi,

with the Q2 2013 update the SelectionChanged event of RadListBox does not fire anymore if an item is selected via code and the RadListBox is currently not visible. Is this new behaviour intended? I've switched back to the previous version.

Regards,
Michael
Georgi
Telerik team
 answered on 03 Jul 2013
1 answer
103 views
Hello.

In our solution we have to display multiple maps in different views of the application. We use different instances of the BingMapProvider for each of the map created. If we enable Tile Caching on at least two of the providers soon we run into the problem of accessing to the same cache file from two threads simultaneously, resulting in exception.

Is there any workaround for this issue?

Thanks.
Andrey
Telerik team
 answered on 03 Jul 2013
2 answers
100 views
Hello

I am trying something that I think the Outlookbar isn't created for, but I've no way else to do it (that I know of so please correct me if I'm wrong). Here is the story:
The view that i am creating has a gridview with grouping. The user can click on an item and edit its value. This can be a string, int, enum and so on. So i created a edittempateselctor that selected the right template. Everything worked, but then the costumer wanted something like the outlookbar to display the values. So I created that, but my problem is that my edittemplate isn't working anymore. The selected template is null. 
This is the working grid code:
<UserControl.Resources>
  <custom:EditTemplateSelector x:Key="EditTemplateSelector" />
</UserControl.Resources>
 
<telerik:RadGridView Grid.Row="2"
 ItemsSource="{Binding ListCollectionView, Mode=TwoWay}"
 SelectionMode="Single"
 AutoGenerateColumns="False"
 CanUserDeleteRows="False"
 CanUserFreezeColumns="False"
 CanUserReorderColumns="False"
 CanUserInsertRows="False"
 RowHeight="30"
 ColumnWidth="200"
 BorderThickness="0"
 ShowColumnHeaders="False"
 ShowGroupPanel="False"
 RowIndicatorVisibility="Collapsed"
  EditTriggers="CellClick">
 <telerik:RadGridView.Columns>
  <aucxis:GridViewDataColumn DataMemberBinding="{Binding SubID}" IsReadOnly="True"/>
  <aucxis:GridViewDataColumn DataMemberBinding="{Binding DataValue}"
   CellEditTemplateSelector="{DynamicResource EditTemplateSelector}"
   Width="Auto"/>
 </telerik:RadGridView.Columns>
</telerik:RadGridView>


this is the edittemplateselector.cs:
public class EditTemplateSelector : DataTemplateSelector
    {
        private IMessageBoxHandler _messageBoxHandler;
 
        public DataTemplate BoolDataTemplate { get; set; }
        public DataTemplate FloatDataTemplate { get; set; }
        public DataTemplate IntDataTemplate { get; set; }
        public DataTemplate StringTemplate { get; set; }
        public DataTemplate TimeSpanTemplate { get; set; }
        public DataTemplate EnumDataTemplate { get; set; }
        public DataTemplate FlagsEnumDataTemplate { get; set; }
        public DataTemplate InOutDoDataTemplate { get; set; }
 
        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            if (_messageBoxHandler == null)
                _messageBoxHandler = DependencyInjection.Container.Resolve<IMessageBoxHandler>();
 
            var dataObject = (DataObject)item;
            if (dataObject == null)
            {
                const string nullValue = "This item has a nullvalue and can't be edited";
                if (_messageBoxHandler != null)
                    _messageBoxHandler.Show(nullValue, "Let op!", MessageBoxButton.OK, MessageBoxImage.Warning);
                else
                    MessageBox.Show(nullValue, "Let op!", MessageBoxButton.OK, MessageBoxImage.Warning);
                return base.SelectTemplate(null, container);
            }
            switch (dataObject.DataValue.GetType().ToString())
            {
                //standard Types
                case "System.Boolean":
                    return BoolDataTemplate;
                case "System.Single":
                    return FloatDataTemplate;
                case "System.Int32":
                    return IntDataTemplate;
                case "System.TimeSpan":
                    return TimeSpanTemplate;
                case "System.String":
                    return StringTemplate;
                //Enum types
                case "Aucxis.VAUC.Shared.Types.AlarmRequestTypes":
                case "Aucxis.VAUC.Shared.Types.Proxy.AutoHandProxy":
                case "Aucxis.VAUC.Shared.Types.Proxy.CO2InjectieStatesProxy":
                case "Aucxis.VAUC.Shared.Types.Proxy.GasmetingStatesProxy":
                case "Aucxis.VAUC.Shared.Types.Proxy.HighLowProxy":
                case "Aucxis.VAUC.Shared.Types.Proxy.InOutTypeProxy":
                case "Aucxis.VAUC.Shared.Types.Proxy.KoelStatesProxy":
                case "Aucxis.VAUC.Shared.Types.Proxy.N2GeneratorKeuzeProxy":
                case "Aucxis.VAUC.Shared.Types.Proxy.N2GeneratorMethodesProxy":
                case "Aucxis.VAUC.Shared.Types.Proxy.N2GeneratorStatesProxy":
                case "Aucxis.VAUC.Shared.Types.Proxy.N2InjectieStatesProxy":
                case "Aucxis.VAUC.Shared.Types.Proxy.O2InjectieStatesProxy":
                case "Aucxis.VAUC.Shared.Types.Proxy.OntdooiTypesProxy":
                case "Aucxis.VAUC.Shared.Types.Proxy.RuimteCO2InjectieStandProxy":
                case "Aucxis.VAUC.Shared.Types.Proxy.RuimteGasModusProxy":
                case "Aucxis.VAUC.Shared.Types.Proxy.RuimteKoelModusProxy":
                case "Aucxis.VAUC.Shared.Types.Proxy.RuimteKoelStandProxy":
                case "Aucxis.VAUC.Shared.Types.Proxy.RuimteN2InjectieStandProxy":
                case "Aucxis.VAUC.Shared.Types.Proxy.RuimteO2InjectieStandProxy":
                case "Aucxis.VAUC.Shared.Types.Proxy.RuimteStatussenProxy":
                case "Aucxis.VAUC.Shared.Types.Proxy.RuimteTypesProxy":
                case "Aucxis.VAUC.Shared.Types.Proxy.VentStatesProxy":
                case "Aucxis.VAUC.Shared.Types.Proxy.VentWinnerProxy":
                case "Aucxis.VAUC.Shared.Types.Proxy.VerdamperModussenProxy":
                case "Aucxis.VAUC.Shared.Types.Proxy.WachtrijCommandoProxy":
                case "Aucxis.VAUC.Shared.Types.Proxy.WachtrijItemTypesProxy":
                    return EnumDataTemplate;
                //flagEnums
                case "Aucxis.VAUC.Shared.Types.Proxy.AlarmTypesProxy":
                case "Aucxis.VAUC.Shared.Types.Proxy.LogTypesProxy":
                    return FlagsEnumDataTemplate;
                case "Aucxis.VAUC.Shared.Types.Proxy.InOutDOProxy":
                    return InOutDoDataTemplate;
                //Custom types (not yet implemented)*/
                default:
                    const string notYetImplemented = "This type is not yet implemented. Edit will result in fail";
                    if (_messageBoxHandler != null)
                        _messageBoxHandler.Show(notYetImplemented, "Let op!", MessageBoxButton.OK, MessageBoxImage.Warning);
                    else
                        MessageBox.Show(notYetImplemented, "Let op!", MessageBoxButton.OK, MessageBoxImage.Warning);
                    return base.SelectTemplate(item, container);
            }
        }
    }

The resourcedictionary with the templates:
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:custom="clr-namespace:Aucxis.VAUC.GUI.Client.Common.Custom;assembly=Aucxis.VAUC.GUI.Client.Common"
                    xmlns:aucxis="http://schemas.aucxis.com/1/wpf"
                    xmlns:converters="clr-namespace:Aucxis.VAUC.GUI.Client.Common.Converters;assembly=Aucxis.VAUC.GUI.Client.Common"
                    xmlns:controls="clr-namespace:Aucxis.iRAD.Controls;assembly=Aucxis.iRAD.Controls"
                    xmlns:touchScreenKeyBoard="clr-namespace:Aucxis.iRAD.Controls.Touch.Keyboard;assembly=Aucxis.iRAD.Controls.Touch"
                    xmlns:touch="clr-namespace:Aucxis.iRAD.Controls.Touch;assembly=Aucxis.iRAD.Controls.Touch"
                    xmlns:views="clr-namespace:Aucxis.VAUC.GUI.Client.Common.Custom.EditTemplates.Views;assembly=Aucxis.VAUC.GUI.Client.Common"
                    xmlns:controls2="clr-namespace:Aucxis.VAUC.GUI.Client.Common.Custom.Controls;assembly=Aucxis.VAUC.GUI.Client.Common">
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="pack://application:,,,/Aucxis.Client.WPF;component/Themes/Generic.xaml" />
        <ResourceDictionary Source="pack://application:,,,/Aucxis.iRAD.Controls.Touch;component/Themes/Generic.xaml" />
        <ResourceDictionary Source="pack://application:,,,/Aucxis.iRAD.Controls;component/Themes/Generic.xaml" />
    </ResourceDictionary.MergedDictionaries>
    <aucxis:IntToDoubleConverter x:Key="IntToDoubleConverter" />
    <aucxis:InverseBooleanConverter x:Key="InverseBooleanConverter" />
    <converters:SingleToDoubleConverter x:Key="SingleToDoubleConverter" />
    <custom:EditTemplateSelector x:Key="EditTemplateSelector">
        <custom:EditTemplateSelector.BoolDataTemplate>
            <DataTemplate>
                <views:BoolView SelectedBool="{Binding DataValue, Mode=TwoWay}"
                               IsEnabled="{Binding ReadOnly, Converter={StaticResource InverseBooleanConverter}}"
                               custom:FocusAttacher.Focus="{Binding ReadOnly, Converter={StaticResource InverseBooleanConverter}}"/>
            </DataTemplate>
        </custom:EditTemplateSelector.BoolDataTemplate>
        <custom:EditTemplateSelector.IntDataTemplate>
            <DataTemplate>
                <controls:NumericUpDown x:Name="NumericUpDown" Value="{Binding DataValue, Mode=TwoWay, Converter={StaticResource IntToDoubleConverter}}"
                                        IsEnabled="{Binding ReadOnly, Converter={StaticResource InverseBooleanConverter}}"
                                        touchScreenKeyBoard:TouchScreenNumericKeyboard.TouchScreenNumericKeyboard="True"
                                        NumberDecimalDigits="0"
                                        custom:FocusAttacher.Focus="{Binding ReadOnly, Converter={StaticResource InverseBooleanConverter}}"/>
            </DataTemplate>
        </custom:EditTemplateSelector.IntDataTemplate>
        <custom:EditTemplateSelector.EnumDataTemplate>
            <DataTemplate>
                <views:EnumView Value="{Binding DataValue, UpdateSourceTrigger=PropertyChanged}"/>
            </DataTemplate>
        </custom:EditTemplateSelector.EnumDataTemplate>
        <custom:EditTemplateSelector.FlagsEnumDataTemplate>
            <DataTemplate>
                <views:FlagsEnumView Value="{Binding DataValue, UpdateSourceTrigger=PropertyChanged}"/>
            </DataTemplate>
        </custom:EditTemplateSelector.FlagsEnumDataTemplate>
        <custom:EditTemplateSelector.FloatDataTemplate>
            <DataTemplate>
                <controls:NumericUpDown x:Name="NumericUpDown" Value="{Binding DataValue, Mode=TwoWay, Converter={StaticResource SingleToDoubleConverter}}"
                                        IsEnabled="{Binding ReadOnly, Converter={StaticResource InverseBooleanConverter}}"
                                        touchScreenKeyBoard:TouchScreenNumericKeyboard.TouchScreenNumericKeyboard="True"
                                        NumberDecimalDigits="2"
                                        custom:FocusAttacher.Focus="{Binding ReadOnly, Converter={StaticResource InverseBooleanConverter}}"/>
            </DataTemplate>
        </custom:EditTemplateSelector.FloatDataTemplate>
        <custom:EditTemplateSelector.InOutDoDataTemplate>
            <DataTemplate>
                <views:InOutDOView DataContext="{Binding DataValue, UpdateSourceTrigger=PropertyChanged}"/>
            </DataTemplate>
        </custom:EditTemplateSelector.InOutDoDataTemplate>
        <custom:EditTemplateSelector.StringTemplate>
            <DataTemplate>
                <touch:TextBox x:Name="txtBox" Text="{Binding DataValue, Mode=TwoWay}"
                               touchScreenKeyBoard:TouchScreenKeyboard.TouchScreenKeyboard="True"
                               IsEnabled="{Binding ReadOnly, Converter={StaticResource InverseBooleanConverter}}"
                               SelectAllOnFocus="True"
                               custom:FocusAttacher.Focus="{Binding ReadOnly, Converter={StaticResource InverseBooleanConverter}}"/>
            </DataTemplate>
        </custom:EditTemplateSelector.StringTemplate>
        <custom:EditTemplateSelector.TimeSpanTemplate>
            <DataTemplate>
                <controls2:TimeSpanPickerTouch x:Name="TimeSpan"
                                            Value="{Binding DataValue, Mode=TwoWay}"
                                            DaysVisible="False"
                                            HorizontalAlignment="Left"
                                            VerticalAlignment="Top"
                                            IsEnabled="{Binding ReadOnly, Converter={StaticResource InverseBooleanConverter}}"
                                            custom:FocusAttacher.Focus="{Binding ReadOnly, Converter={StaticResource InverseBooleanConverter}}"/>
            </DataTemplate>
        </custom:EditTemplateSelector.TimeSpanTemplate>
    </custom:EditTemplateSelector>
</ResourceDictionary>


Not working code:
<controls:RadOutlookBar Grid.Row="2"
 ItemsSource="{Binding Groups}"
 IsMinimizable="False">
 <controls:RadOutlookBar.TitleTemplate>
  <DataTemplate>
   <Label Content="{Binding Header}"/>
  </DataTemplate>
 </controls:RadOutlookBar.TitleTemplate>
 <controls:RadOutlookBar.ItemTemplate>
  <DataTemplate>
    <Label Content="{Binding Header}"/>
  </DataTemplate>
 </controls:RadOutlookBar.ItemTemplate>
 <controls:RadOutlookBar.ContentTemplate>
  <DataTemplate>
   <telerik:RadGridView Grid.Row="2"
    ItemsSource="{Binding DataObjects, Mode=TwoWay}"
    SelectionMode="Single"
    AutoGenerateColumns="False"
    CanUserDeleteRows="False"
    CanUserFreezeColumns="False"
    CanUserReorderColumns="False"
    CanUserInsertRows="False"
    RowHeight="30"
    ColumnWidth="200"
    BorderThickness="0"
    ShowColumnHeaders="False"
    ShowGroupPanel="False"
    RowIndicatorVisibility="Collapsed"
    EditTriggers="CellClick">
    <telerik:RadGridView.Columns>
      <aucxis:GridViewDataColumn DataMemberBinding="{Binding SubID}" IsReadOnly="True"/>
      <aucxis:GridViewDataColumn DataMemberBinding="{Binding DataValue}"
       CellEditTemplateSelector="{StaticResource EditTemplateSelector}"
       Width="Auto"/>
    </telerik:RadGridView.Columns>
   </telerik:RadGridView>
  </DataTemplate>
 </controls:RadOutlookBar.ContentTemplate>
</controls:RadOutlookBar>

So when I use this last implementation the datatemplates in the Edittemplateselector returns null.
They are In the same project in the same view, I just don't get it :)
Waut
Top achievements
Rank 1
 answered on 03 Jul 2013
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?