Hello,
I have some problems using Radcombobox.
The list with the data is Alignment to right.
if I choose an item from the list is longer than the width of Radcombobox
the text in Radcombobox has been cut to the right and no to the left.
i have attaced sample code here.
Thanks
<
Border Grid.Row="2" Style="{StaticResource BorderCombo_Details}" Width="140" HorizontalAlignment="Right" Grid.Column="3" VerticalAlignment="Top">
<telerikInput:RadComboBox IsReadOnly="True" KeyUp="OnKeyUpClear" FlowDirection="RightToLeft" HorizontalAlignment="Right" x:Name="cmbVolStatus" TabIndex="4"
SelectionChanged="cmbVolStatus_SelectionChanged"
Style="{StaticResource RadComboBox_Details}"
SelectedValue="{Binding Source={StaticResource VolunteersVS},
Path=VD_VolStatusID, Mode=TwoWay,
ValidatesOnDataErrors=True,
NotifyOnValidationError=True}"
Validation.Error="Validation_Error"
SelectedValuePath="VS_ID"
DisplayMemberPath="VS_Desc"/>
</Border>
private
void
OnDragInfo(
object
sender, DragDropEventArgs e)
{
if
(e.Options.Status == DragStatus.DragComplete)
{
var listBox = e.Options.Source.FindItemsConrolParent()
as
ItemsControl;
var itemsSource = listBox.ItemsSource
as
IList;
var operation = e.Options.Payload
as
DragDropOperation;
itemsSource.Remove(operation.Payload);
}
}
private
void
OnDropInfo(
object
sender, DragDropEventArgs e)
{
var destination = e.Options.Destination;
if
(e.Options.Status == DragStatus.DropPossible && destination
is
ListBoxItem)
{
var listBox = destination.FindItemsConrolParent()
as
ListBox;
FrameworkElement rootChild = VisualTreeHelper.GetChild(listBox, 0)
as
FrameworkElement;
Storyboard dropStoryboard = rootChild.FindResource(
"DropStoryboard"
)
as
Storyboard;
dropStoryboard.Begin();
//Get the DropCueElemet:
var dropCueElement = (VisualTreeHelper.GetChild(listBox, 0)
as
FrameworkElement).FindName(
"DropCueElement"
)
as
FrameworkElement;
var operation = e.Options.Payload
as
DragDropOperation;
//Get the parent of the destination:
var visParent = VisualTreeHelper.GetParent(destination)
as
UIElement;
//Get the spacial relation between the destination and its parent:
var destinationStackTopLeft = destination.TransformToVisual(visParent).Transform(
new
Point());
var yTranslateValue = operation.DropPosition == DropPosition.Before ? destinationStackTopLeft.Y : destinationStackTopLeft.Y + destination.ActualHeight;
dropCueElement.RenderTransform =
new
TranslateTransform() { Y = yTranslateValue };
e.Handled =
true
;
}
if
(e.Options.Status == DragStatus.DropPossible && destination
is
ListBox)
{
var listBox = destination
as
ListBox;
FrameworkElement rootChild = VisualTreeHelper.GetChild(listBox, 0)
as
FrameworkElement;
Storyboard dropStoryboard = rootChild.FindResource(
"DropStoryboard"
)
as
Storyboard;
dropStoryboard.Begin();
//Get the DropCueElemet:
var dropCueElement = (VisualTreeHelper.GetChild(listBox, 0)
as
FrameworkElement).FindName(
"DropCueElement"
)
as
FrameworkElement;
var operation = e.Options.Payload
as
DragDropOperation;
// Get the size of the items:
var itemsPresenter = listBox.GetTemplateChild<FrameworkElement>(
"ItemsPresenterElement"
);
var panel = VisualTreeHelper.GetChild(itemsPresenter, 0)
as
Panel;
if
(panel !=
null
)
{
var yTranslateValue = panel.ActualHeight;
dropCueElement.RenderTransform =
new
TranslateTransform() { Y = yTranslateValue };
}
}
//Hide the DropCue:
if
(e.Options.Status == DragStatus.DropImpossible || e.Options.Status == DragStatus.DropCancel || e.Options.Status == DragStatus.DropComplete)
{
var listBox = destination
as
ListBox;
if
(listBox ==
null
)
{
listBox = e.Options.Destination.FindItemsConrolParent()
as
ListBox;
}
FrameworkElement rootChild = VisualTreeHelper.GetChild(listBox, 0)
as
FrameworkElement;
Storyboard dropStoryboard = rootChild.FindResource(
"DropStoryboard"
)
as
Storyboard;
dropStoryboard.Stop();
}
//Place the item:
if
(e.Options.Status == DragStatus.DropComplete && destination
is
ListBoxItem)
{
var listBox = e.Options.Destination.FindItemsConrolParent()
as
ListBox;
var itemsSource = listBox.ItemsSource
as
IList;
var destinationIndex = itemsSource.IndexOf(e.Options.Destination.DataContext);
var operation = e.Options.Payload
as
DragDropOperation;
var insertIndex = operation.DropPosition == DropPosition.Before ? destinationIndex : destinationIndex + 1;
itemsSource.Insert(insertIndex, operation.Payload);
listBox.Dispatcher.BeginInvoke(
new
Action(() =>
{
listBox.SelectedIndex = insertIndex;
}));
}
//Place the item:
if
(e.Options.Status == DragStatus.DropComplete && destination
is
ListBox)
{
var listBox = e.Options.Destination
as
ListBox;
var itemsSource = listBox.ItemsSource
as
IList;
var operation = e.Options.Payload
as
DragDropOperation;
itemsSource.Add(operation.Payload);
}
}
private
void
OnDropQuery(
object
sender, DragDropQueryEventArgs e)
{
var destination = e.Options.Destination;
if
(e.Options.Status == DragStatus.DropDestinationQuery && destination
is
ListBoxItem)
{
var listBox = destination.FindItemsConrolParent()
as
ListBox;
//Cannot place na item relative to itself:
if
(e.Options.Source == e.Options.Destination)
{
return
;
}
//Get the spatial relation between the destination item and the vis. root:
var destinationTopLeft = destination.TransformToVisual(Window.GetWindow(destination)).Transform(
new
Point());
//Should the new Item be moved before or after the destination item?:
bool
placeBefore = (e.Options.CurrentDragPoint.Y - destinationTopLeft.Y) < destination.ActualHeight / 2;
var operation = e.Options.Payload
as
DragDropOperation;
operation.DropPosition = placeBefore ? DropPosition.Before : DropPosition.After;
e.QueryResult =
true
;
e.Handled =
true
;
}
if
(e.Options.Status == DragStatus.DropDestinationQuery && destination
is
ListBox)
{
var listBox = destination
as
ListBox;
// Cannot drop the last or only item of the list box within the same list box:
var operation = e.Options.Payload
as
DragDropOperation;
//if (listBox.ItemsSource != null && listBox.ItemsSource.Cast<object>().Last() != operation.Payload)
//{
e.QueryResult =
true
;
e.Handled =
true
;
//}
//else
//{
// e.QueryResult = false;
// e.Handled = true;
//}
}
}
private
void
OnDragQuery(
object
sender, DragDropQueryEventArgs e)
{
if
(e.Options.Status == DragStatus.DragQuery)
{
var sourceControl = e.Options.Source;
e.QueryResult =
true
;
e.Handled =
true
;
var dragCue = RadDragAndDropManager.GenerateVisualCue(sourceControl);
dragCue.HorizontalAlignment = HorizontalAlignment.Left;
dragCue.Content = sourceControl.DataContext;
e.Options.DragCue = dragCue;
e.Options.Payload =
new
DragDropOperation() { Payload = sourceControl.DataContext };
}
if
(e.Options.Status == DragStatus.DropSourceQuery)
{
e.QueryResult =
true
;
e.Handled =
true
;
}
}
<Window x:Class="RadControlsWpfApp2.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"
Title="MainWindow" Height="350" Width="525">
<Grid>
<telerik:RadGridView
ItemsSource="{Binding Items}"
AutoGenerateColumns="False">
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn DataMemberBinding="{Binding Path=B.Id}" Header="Works" ></telerik:GridViewDataColumn>
<telerik:GridViewDataColumn DataMemberBinding="{Binding Path=B.C.Name}" Header="Fails" ></telerik:GridViewDataColumn>
</telerik:RadGridView.Columns>
</telerik:RadGridView>
</Grid>
</Window>
namespace RadControlsWpfApp2
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
var model = new Model();
DataContext = model;
}
}
}
using System.Collections.Generic;
namespace RadControlsWpfApp2
{
class Model
{
public Model()
{
Items = new List<A> {new A(), new A()};
}
public IList<A> Items { get; set; }
}
class A
{
public A()
{
B = new B();
}
public B B { get; set; }
}
class B
{
public B()
{
C = new C();
Id = "3213123";
}
public string Id { get; set; }
public C C { get; set; }
}
class C
{
public C()
{
Name = "Test";
}
public string Name { get; set; }
}
}
Simple code:
<
Window
x:Class
=
"MainWindow"
Height
=
"350"
Width
=
"525"
xmlns:telerik
=
"http://schemas.telerik.com/2008/xaml/presentation"
>
<
Grid
>
<
telerik:RadTabControl
>
<
telerik:RadTabItem
Header
=
"Calendar"
>
<
telerik:RadDocking
>
</
telerik:RadDocking
>
</
telerik:RadTabItem
>
<
telerik:RadTabItem
Header
=
"Colors"
>
<
telerik:RadDocking
>
</
telerik:RadDocking
>
</
telerik:RadTabItem
>
<
telerik:RadTabItem
Header
=
"Quote"
>
<
telerik:RadDocking
>
</
telerik:RadDocking
>
</
telerik:RadTabItem
>
</
telerik:RadTabControl
>
</
Grid
>
</
Window
>