Telerik Forums
UI for WPF Forum
1 answer
231 views
Hello All,
   I just wanted to submit a solution I found that allows me to attach a file browser dialog to a textbox field of a data form (see attached example1.png).   Basically I wanted a browse button next to the text box that would open a filedialog and replace the textbox's text property with the selected file's path.   I found this cool class in a blog post ( blogpost )  that allow someone to attach a filebrowser dialog to a textbox and re-engineered it in VB.NET (see the blog posting for the C# version).  I then created a User Control that contains the button and textbox and attaches to a custom filter field.  Next I created a class call DataFormImageFileBrowser that Inherits from the DataFormDataField and replaces the textbox with the user control.  Finally I bound the custom DataFormDataField in the AutoGeneratingField event and viola it works... here my code for the OpenFileDialogEx and the DataFormImageFileBrowser

Imports System
Imports Microsoft.Win32
Imports Telerik.Windows
Imports Telerik.Windows.Controls
 
Public Class OpenFileDialogEx
    Public Shared ReadOnly FilterProperty As DependencyProperty = DependencyProperty.RegisterAttached("Filter", GetType(String), GetType(OpenFileDialogEx), New PropertyMetadata("All documents (.*)|*.*", Sub(d, e) AttachFileDialog(DirectCast(d, TextBox), e)))
    Public Shared Function GetFilter(element As UIElement) As String
        Return DirectCast(element.GetValue(FilterProperty), String)
    End Function
 
    Public Shared Sub SetFilter(element As UIElement, value As String)
        element.SetValue(FilterProperty, value)
    End Sub
 
 
    Private Shared Sub AttachFileDialog(textBox As TextBox, args As DependencyPropertyChangedEventArgs)
        Dim parent = DirectCast(textBox.Parent, Panel)
        ''added this because there was a problem with double binding and it was causing the filebrowser dialog to pop up twice
        Dim tag = TryCast(parent.Tag, String)
        If Not IsNothing(tag) Then Return
        parent.Tag = "already bound"
        AddHandler parent.Loaded, Sub()
 
                                      Dim button = DirectCast(parent.Children.Cast(Of Object)().FirstOrDefault(Function(x) TypeOf x Is Button), Button)
                                      Dim filter = DirectCast(args.NewValue, String)
                                      AddHandler button.Click, Sub(s, e)
                                                                   Dim dlg = New OpenFileDialog()
                                                                   dlg.Filter = filter
                                                                   Dim result = dlg.ShowDialog()
                                                                   If result = True Then
                                                                       textBox.Text = dlg.FileName
                                                                   End If
                                                               End Sub
                                  End Sub
    End Sub
End Class
 
Public Class DataFormImageFileBrowser
    Inherits DataFormDataField
 
    Protected Overrides Function GetControlBindingProperty() As DependencyProperty
        Return TextBox.TextProperty
    End Function
 
    Protected Overrides Function GetControl() As Control
        Dim fd = New OpenFileDialogUC("Image file (pdf,png,gif,jpg,bmp,tif,emf,wmf)|*.pdf;*.png;*.gif;*.jpg;*.bmp;*.jpeg;*.tiff;*.tif;*.emf;*.wmf")
 
        Dim dependencyProperty As DependencyProperty = GetControlBindingProperty()
        If Not IsNothing(DataMemberBinding) Then
            Dim binding = DataMemberBinding
            fd.FileNameTbx.SetBinding(dependencyProperty, binding)
        End If
 
        Return fd
    End Function
End Class


Here is the code for the UserControl:
<UserControl x:Class="OpenFileDialogUC"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:src="clr-namespace:CarWashInventoryManagement"
             mc:Ignorable="d" >
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="Auto"/>
        </Grid.ColumnDefinitions>
        <TextBox x:Name="FileNameTbx" MinWidth="100" src:OpenFileDialogEx.Filter="{Binding FilterStr}" Grid.Column="0" />
        <Button Grid.Column="1">Browse</Button>
    </Grid>
</UserControl>

and its code behind:
Public Class OpenFileDialogUC
    Public Property FilterStr As String = String.Empty
    Public Sub New(_filter As String)
        FilterStr = _filter
        DataContext = Me
        InitializeComponent()
    End Sub
End Class


here is the code for the AutoGeneratingField for the RadDataForm
ElseIf e.PropertyName = "FileName" Then
        Dim df = New DataFormImageFileBrowser()
        df.Label = e.DataField.Label
        df.DataMemberBinding = e.DataField.DataMemberBinding
        e.DataField = df
        e.DataField.Label = "File Name"

I thought this was pretty cool so I thought I would share...
Maya
Telerik team
 answered on 01 May 2013
4 answers
170 views
Hi,

we've got an issue with the saving functionality of RadDocking.
When I call the RadDocking.SaveLayout() function, it will create a xml like (this is a snippet from the whole file):
<RadSplitContainer Dock="DockedTop" Orientation="Vertical">
    <Items>
        <RadPaneGroup RelativeWidth="100" RelativeHeight="100" SplitterChange="422,180833333333" SelectedIndex="0">
            <Items>
                <RadPane SerializationTag="LineAppearancesPane" IsDockable="True" />
            </Items>
        </RadPaneGroup>
        <RadPaneGroup RelativeWidth="100" RelativeHeight="300" SplitterChange="554,5425" SelectedIndex="0">
            <Items>
                <RadPane SerializationTag="CallControlWheelPane" IsDockable="True" Header="" CanFloat="False" />
            </Items>
        </RadPaneGroup>
    </Items>
</RadSplitContainer>

When I do a loadLayout based on this XML, one of our panes is completely hidden, it looks like it is out of the screen. However, when I change the SplitterChange to 422, it's working correctly again. So it looks like a problem with the huge number of digits within that SplitterChange.

So far, this problem only occurs on the machine of a tester, I couldn't reproduce a savelayout which would give me such a strange splitterchange as well. However, when I load his settings on my machine, I've got the same issue, so it must be in the xml, and somewhere in the savelayout.

We are running RadControls for WPF v.2013.1.220.40
Is this a known issue, or a quick solution/workaround for it? I could read the xml string again and change all SplitterChange values to integers as a temporary workaround, but prefer a more robust solution ;)

Thanks in advance,
Rutger
Rutger Kars
Top achievements
Rank 1
 answered on 01 May 2013
1 answer
49 views
If somehow when min/max values are binded and max value become less than min, it causes huge memory leak
Ves
Telerik team
 answered on 01 May 2013
2 answers
250 views
Hello,
I've started creating custom tool based on resize tool, however I'd like to have:
a) press button -> tool is runnig and changes are applied to image
b) no tool settings window is displayed.

Currently tool settings window with reset button is diplaying (I do not need that)
And Tool is not commiting itself. I would like to automatically commit changes similar to flip or rotate.
Petya
Telerik team
 answered on 01 May 2013
5 answers
583 views
I am using Implicit Themes in my WPF app, like so:
<Application x:Class="Green.App"
    xmlns:local="clr-namespace:Green">
    <Application.Resources>
      <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary>
                    <local:AppBootstrapper x:Key="bootstrapper" />
                </ResourceDictionary>
                <ResourceDictionary Source="/Telerik.Windows.Themes.Windows8;component/Themes/System.Windows.xaml"/>
                <ResourceDictionary Source="/Telerik.Windows.Themes.Windows8;component/Themes/Telerik.Windows.Controls.xaml"/>
                <ResourceDictionary Source="/Telerik.Windows.Themes.Windows8;component/Themes/Telerik.Windows.Controls.Input.xaml"/>
                <ResourceDictionary Source="/Telerik.Windows.Themes.Windows8;component/Themes/Telerik.Windows.Controls.Navigation.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>
</Application>

It doesn't seem to be applying to User Controls that I create, do I need to do something different?  I noticed here -->Implicit Styles that it references using the "Themes.Implicit" folder...

I did what I have shown above and added a reference to "Telerik.Windows.Themes.Windows8", the No Xaml version.
Vanya Pavlova
Telerik team
 answered on 01 May 2013
3 answers
115 views
Hello,

In my wpf application i've a feature of drag and drop of grid view rows and i need to add an image to one cell in the row dragged.

To do this, i create the image object dynamically with this code:
           
var cellImage = new Image() { Width = 20, Height = 20 };
var imageUri = "../AppResources/Images/flag.png";
cellImage.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(imageUri, UriKind.Relative));


And i add the image to the cell i want:
this.jobsGridView.CurrentCell.ParentRow.Cells[2].Content = cellImage;

The image is added to the cell of the dragged row but also added to some other rows in the gridview.

Do you know the cause of this behavior?

Thanks.
Nick
Telerik team
 answered on 01 May 2013
3 answers
271 views
Hi!

I'm trying to get RadListBox accept items from RadTreeView but my RadListBox does not seem to accept drops from TreeView. Do I need to have somekind of converter even though the actual payload object is same as what I have loaded in the listbox. In treeview I'm using HierarchicalDataTemplate which shows individual users (User class) with some data from related entity tables. ListBox only shows user's username but it uses the same User class.

        <Style x:Key="DraggableListBoxItem" TargetType="telerik:RadListBoxItem">
            <Setter Property="telerik:DragDropManager.AllowCapturedDrag" Value="True"/>
            <Setter Property="telerik:DragDropManager.AllowDrag" Value="True" />
            <Setter Property="telerik:DragDropManager.TouchDragTrigger" Value="TapAndHold"/>
        </Style>
         
        <DataTemplate x:Key="ListBoxItemTemplate">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>
                <Image Source="/Dashboard_UserExtension;component/Images/usericon.png" Margin="10 0 0 0" Width="16" Height="16" Grid.Column="0"
                        HorizontalAlignment="Left" />
                <TextBlock Text="{Binding Username}" FontSize="12" FontFamily="Segoe UI" Grid.Column="1" Margin="10 0 0 0" HorizontalAlignment="Left" />
            </Grid>
        </DataTemplate>
 
<telerik:RadListBox
                x:Name="AdminUserBox"
                AllowDrop="True"
                ItemTemplate="{StaticResource ListBoxItemTemplate}"
                ItemContainerStyle="{StaticResource DraggableListBoxItem}"
                HorizontalAlignment="Left"
                Margin="0,10,0,1"
                Width="150"
                ItemsSource="{Binding AdminUserList}" Drop="AdminUserBox_Drop">
                <telerik:RadListBox.DragVisualProvider>
                    <telerik:ScreenshotDragVisualProvider />
                </telerik:RadListBox.DragVisualProvider>
                <telerik:RadListBox.DragDropBehavior>
                    <telerik:ListBoxDragDropBehavior AllowReorder="True" />
                </telerik:RadListBox.DragDropBehavior>
            </telerik:RadListBox>
 
<telerik:RadTreeView x:Name="UserTreeView"
                                 HorizontalAlignment="Left"
                                 Margin="0,10,-2,0"
                                 Width="220"
                                 IsDragDropEnabled="True"
                                 ItemTemplate="{StaticResource UserTemplate}"
                                 ItemsSource="{Binding UserList}"
                                 IsLoadOnDemandEnabled="False"
                                 IsSingleExpandPath="True"
                                 ItemContainerStyle="{StaticResource UsersItemContainerStyle}"
                                 AllowDrop="False"
                                 >
            </telerik:RadTreeView>


My other problem is how to handle drop event when dragging item from listbox to another listbox. Both listbox have AllowDrop=true and items can be dropped to each other but I'm not sure how to handle drop event as it does not seem to fire on drop. Do I need to use this DragAndDropManager?

private void AdminUserBox_Drop(object sender, System.Windows.DragEventArgs e)
{
    MessageBox.Show("Drop!"); // Not shown when dropping to AdminUserBox
}

Drag and Drop problems

I tried to follow Telerik's DragAndDrop samples but I'm little bit confused if I should use DragAndDropManager or not...

I just saw a post about renewing the RadTreeView, maybe I need to wait for that.

Br,

Kalle
Nick
Telerik team
 answered on 01 May 2013
1 answer
124 views
Hi,

The TimeLine items randomly positioned on the rows.
- Group 1
XXXXXXXXXXXX   O   O   O    O   O   O     O   O   O
         XXXXXXXXXXXX XXXXXXXXXXXX  
               
+ Group 2

Is it possible to choose a row item ? I must have a period followed by several events without duration on each row in the same group :

- Group 1
XXXXXXXXXXXX   O   O   O
         XXXXXXXXXXXX    O   O   O
                  XXXXXXXXXXXX   O  O  O

+ Group 2

Tsvetie
Telerik team
 answered on 01 May 2013
2 answers
157 views
 I have to GridViewDataColumns in a single grid.  Both have DataMemberBinding set. Both display the information in the grid however filtering does not work on the second one. The only difference betweend the two is one has a long Path than the other. Are there any known bugs with this and is there a work around?

This one works
   <telerik:GridViewDataColumn Width="75"
                                                    MinWidth="75"
                                                    DataMemberBinding="{Binding Path=PaymentSubTypeDetail.PurchaseBased}"
                                                    Header="%"
                                                    IsFilterable="True"
                                                    IsSortable="True" />

This one doesn't work
<telerik:GridViewDataColumn Width="*"
                                                    MinWidth="100"
                                                    DataMemberBinding="{Binding  Path=PaymentSubTypeDetail.ReceiptTicketStyle.Name}"                                                  
                                                    Header="Receipt Style"
                                                    IsFilterable="True"
                                                    IsSortable="True" / >
                       
               
Dimitrina
Telerik team
 answered on 01 May 2013
1 answer
120 views
I have an issue with highlighting an item when typing in the combobox. It's reproducible with the WPF Controls Examples like this:

- Open WPF Controls Examples
- All controls
- Select combobox demo
- In more ComboBox Examples select the Data Binding example
- Click on the top combobox (The not editable sample)
- Type PB
- The item 'PB knackebrod AB' should be highlighted, but it's not
- Press enter
- The tem 'PB knackebrod AB' is selected

So it does find the correct item, but does not highlight it.

Could you please fix this?
George
Telerik team
 answered on 01 May 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?