Telerik Forums
UI for WPF Forum
0 answers
31 views

Hi All,

I am developing a tool for Autodesk Revit using the pyrevit extension and IronPython. For this, I have implemented a custom control called IntegerUpDown, which I need to use in my tool. I tested the control in Visual Studio, and it works well. However, I am struggling to use my control in pyrevit by referencing it's name space in my main xaml file, considering the structure of my project attached below:

Please check my references:

IntegerUpDown.xaml :

<UserControl 
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

             MinWidth="50">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="Auto"/>
        </Grid.ColumnDefinitions>

        <Grid Grid.Column="0">
            <TextBox x:Name="NumericText" Grid.Column="0"
                     Text="0"
                     TextAlignment="Center"
                     BorderBrush="Black" Margin="0,0,0.2,0" />
        </Grid>
        <Grid Grid.Column="1">
            <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <RepeatButton x:Name="PART_IncreaseButton" Click="btnIncrease_Click" Grid.Row="0" Margin="0,0,0,0.1"
				  Width="15" BorderThickness="0.75">
                <Polygon x:Name="PART_Up_Polygon" 
                         HorizontalAlignment="Center" 
                         VerticalAlignment="Center" Margin="2"
						 StrokeThickness="0.5" Stroke="Transparent" 
                         Points="0,0 -2,5 2,5" Stretch="Fill" Fill="Black"/>
            </RepeatButton>
            <RepeatButton x:Name="PART_DecreaseButton" Click="btndecrease_Click"  Grid.Row="1" Margin="0,0.1,0,0" 
				  Width="15" BorderThickness="0.75">
                <Polygon x:Name="PART_Down_Polygon" HorizontalAlignment="Center" 
                         VerticalAlignment="Center" Margin="2"
						 StrokeThickness="0.5" Stroke="Transparent" 
                         Points="-2,0 2,0 0,5 " Stretch="Fill" Fill="Black"/>
            </RepeatButton>
        </Grid>

    </Grid>
</UserControl>


IntegerUpDown.py:

import os, clr, wpf

from System.Windows.Controls import UserControl


script_path = os.path.dirname(__file__)

class IntegerUpDown(UserControl):
    def __init__(self):
        xaml_path = os.path.join(script_path, 'IntegerUpDown.xaml')
        wpf.LoadComponent(self, xaml_path)

    def btnIncrease_Click(self, sender, e):
        num = int(self.NumericText.Text)
        num += 1
        self.NumericText.Text = str(num)

    def btnDecrease_Click(self, sender, e):
        num = int(self.NumericText.Text)
        num = max(num - 1, 0)
        self.NumericText.Text = str(num)


grids.xaml  (Main xaml):

<Window
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        <!--I am struggling what putting here?-->
        xmlns:local="clr-namespace:...."
        Title="Grids"
        Height="500"  Width="340"
        WindowStartupLocation="CenterScreen">
    <Grid Margin="10">
        <Grid.RowDefinitions>
            <RowDefinition Height="7*"/>
            <RowDefinition Height="86*"/>
            <RowDefinition Height="7*"/>
        </Grid.RowDefinitions>

        <DockPanel >
            <Label Content="Nom :" />
            <TextBlock Text="Grid for Revit" Width="150" Margin="0,4,0,0" />
        </DockPanel>

        <TabControl Grid.Row="1">
            <TabItem Header="X" Width="50">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="65*"/>
                        <ColumnDefinition Width="35*"/>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="7*"/>
                        <RowDefinition Height="7*"/>
                        <RowDefinition Height="79*"/>
                        <RowDefinition Height="7*"/>
                    </Grid.RowDefinitions>
                    <DockPanel Grid.ColumnSpan="2">
                        <Label Content="Position:" Margin="0,0,40,0"/>
                        <Label Content="Repeter x:" Margin="0,0,40,0"/>
                        <Label Content="Espacement:"/>
                    </DockPanel >
                    <DockPanel Grid.Row="1" Grid.ColumnSpan="2">
                        <TextBox Width="50" Text="0.00" Margin="0,0,5,0"/>
                        <TextBlock Text="(m)" Margin="0,0,25,0" Width="20"/>
                        <IntegerUpDown x:Name="MyUpDown" Minimum="00" Margin="0,0,50,0"/>
                        <TextBox Width="50" Text="0.00" Margin="0,0,5,0"/>
                        <TextBlock Text="(m)" Width="20" HorizontalAlignment="Left" />
                    </DockPanel>
                    <ListBox Grid.Row="2" Margin="0,5,0,0">
                        <ListBoxItem>
                            1
                        </ListBoxItem>
                        <ListBoxItem>
                            2
                        </ListBoxItem>
                        <ListBoxItem>
                            3
                        </ListBoxItem>
                    </ListBox>
                    <StackPanel Grid.Column="1" Grid.Row="2">
                        <Button Name="ajouter_X" Content="Ajouter" Click="ajouter_X_Click" VerticalAlignment="Top" Margin="5,50,5,10"/>
                        <Button Name="supprimer_X" Content="Supprimer" Click="supprimer_X_Click"  Margin="5,0,5,10"/>
                        <Button Name="supprimer_tout_X" Content="Supprimer tout" Click="supprimer_tout_X_Click"  Margin="5,0,5,10"/>
                    </StackPanel>
                </Grid>
            </TabItem>
         </TabControl>

        <DockPanel Grid.Row="2">
            <Button Content="Appliquer" Width="100" Height="25"/>
            <Button Content="Fermer" Width="100" Height="25"  Click="Fermer_Click" HorizontalAlignment="Right"/>
        </DockPanel>

    </Grid>
</Window>


Grids_script.py (Main script) :


# -*- coding: UTF-8 -*-
import wpf, clr, os

from System.Windows import Window


script_path = os.path.dirname(__file__)
class Mywindow(Window):
    def __init__(self):
        xaml_path = os.path.join(script_path, 'grids.xaml')
        wpf.LoadComponent(self, xaml_path)

    def ajouter_X_Click(self, sender, e):
        pass

    def supprimer_X_Click(self, sender, e):
        pass

    def supprimer_tout_X_Click(self, sender, e):
        pass

    def Fermer_Click(self, sender, e):
        self.Close()

if __name__ == "__main__":
    Grids = Mywindow()
    Grids.ShowDialog()

 

Any help would be appreciated

 

Thanks.

 

 

Redouane
Top achievements
Rank 1
 asked on 15 Jan 2025
1 answer
23 views

Hi there, 

I implemented a drag and drop behavior within a radgridview based on this page: https://docs.telerik.com/devtools/wpf/controls/dragdropmanager/how-to/howto-draganddrop-within-radgridview and it works correctly.

But now I need to introduce grouping of elements based on a specific property

<telerik:RadGridView.GroupDescriptors>
	<telerik:GroupDescriptor Member="GroupingField" SortDirection="Ascending" />
</telerik:RadGridView.GroupDescriptors>

I was able to modify the RadGridViewRowDragDropBehavior class so that dragging is limited to the current group, but when it is allowed, the dragged element falls to the last position in the group instead of the desired position. For example:

Group A
    Item 1
    Item 2
Group B
   Item 3
   Item 4
   Item 5
   Item 6
Group C
   Item 7

when I drag “item 3” and drop it after “item 4” the result is as follows: 

Group B
   Item 4
   Item 5
   Item 6
   Item 3

I tied to solve the problem by invoking the RadGridView.Rebind() method at the end of RadGridViewRowDragDropBehavior.OnDrop, but it does not work and I don't think this is the best solution, any suggestions?

Thanks

 

 

 

Carlo
Top achievements
Rank 1
Iron
 answered on 14 Jan 2025
0 answers
26 views

Hi,

I am using the TreeListView control and I've come along with it pretty well. A few days ago, I stumbled upon a small problem which I couldn't solve so far.

The bottom and right border of the TreeListView control appear to be thicker than the left and top border. This is caused by the interior cell borders: each cell seems to have a border on the bottom and right.

As soon as the cell border and the TreeListView border are directly next to each other, there's an 'illusion' created that the overall border is double in thickness.

E.g., as soon as I scroll to the bottom of the table, the border of the last cell will 'connect' with the overall table border:

In the attached screenshot, each border has a thickness of 1. But two borders which are layouted directly next to each other will make it look like the border has a thickness of 2.

 

The same problem appears on the right side of the table. I have some table rows which do not show borders at all, which is solved with a style selector (red arrow in the screenshot). This leads to a different thickness of the right border in comparison to a 'normal' row (blue arrow in the screenshot).

 

How could I solve this issue? My suggestion would be to use a style / template which is only applied to the last row / column. In the last row, the bottom border would have a thickness of 0; in the last column, the right border would have a thickness of 0. The bottom right cell would have no own borders at all because its optical borders are provided by the left and upper cell and the overall table border.

But I have no idea how to apply this. I have seen such solutions in other projects but I can't manage to apply it to the Telerik TreeListView. I Imagine it could be implemented by a mechanism which automatically determines the last row and cell and then applies a different template.

Thanks a lot in advance! Any help is highly appreciated.

 

Alexander
Top achievements
Rank 1
 asked on 14 Jan 2025
1 answer
38 views

Hi,

I am using a RadGridView with an unmodified GreenTheme. I disabled Grouping Columns, but the Area to group columns at the top of the grid is still shown and I can not find an easy way to hide it.

How can I make it disappear?

 

<telerik:RadGridView
    CanUserGroupColumns="False"
    ScrollViewer.VerticalScrollBarVisibility="Visible"
    ScrollViewer.CanContentScroll="True"
    telerik:StyleManager.Theme="{StaticResource GreenTheme}"
    ItemsSource="{Binding FilteredMessages}"
    VerticalAlignment="Stretch"
    ScrollMode="RealTime"
    IsReadOnly="True" />
Thanks in advance,

Roland
Stenly
Telerik team
 answered on 14 Jan 2025
1 answer
75 views

I have a new WPF application, one that I am updating from Framework to Core.   Everything has been converted and working properly except for one thing: the CheckBoxControl controls are not displaying.  All other controls, including things like RadButton are RadGridView, are all displaying and working perfectly.    I deleted the BIN and OBJ folders and cleaned the project, no change.   

If I change the code to use the standard WPF CheckBox control everything works correctly.

The main project of the solution has this inside it's project file:

    <PackageReference Include="Telerik.UI.for.Wpf.80.Xaml" Version="2024.4.1213" />
    <PackageReference Include="Telerik.Windows.Themes.Crystal.for.Wpf" Version="2024.4.1213" />

I have other projects in the solution that have working Telerik controls (except for the CheckBoxControl) that contain this in their project files:

    <PackageReference Include="Telerik.UI.for.Wpf.80.Xaml" Version="2024.4.1213" />

in the xaml form:

<telerik:CheckBoxControl Grid.Row="5" Grid.Column="0" Name="ChkCustomProcess"  HorizontalAlignment="Right" VerticalAlignment="Center"  Margin="5" />

// I have tried this with and without binding to the IsChecked property.

Everything else works fine, including the theming, except for the invisible CheckBox Control.   IntelliSense works in the editor; no compilation errors or warnings.

I am using the NuGet packages from Telerik.  There are no pending updates. I am not referencing any NoXaml packages.

It's probably something simple I am missing. Any thoughts and ideas would be greatly appreciated.

Thanks,
Lou

Martin Ivanov
Telerik team
 answered on 13 Jan 2025
0 answers
72 views

I am currently using DevExpress but considering switching to Telerik.

I downloaded the Telerik UI for WPF demo version and applied it to my existing application for evaluation. However, I encountered an issue and would like to ask for assistance.

I created a project using the "Telerik WPF Application (.NET Framework)" template, ran the blank project, and resized the window. Since our users work with four 2560x1440 monitors, I resized the window to fill all four monitors.

At this point, the following error occurred:

Unhandled exception of type 'System.OutOfMemoryException' occurred in PresentationCore.dll.
There is not enough memory to continue the execution of the program.

This exception does not occur in Microsoft WPF projects.

Before purchasing, I would like to confirm if there is a solution to this issue.

Thank you in advance for your response.

kihwan
Top achievements
Rank 1
 asked on 13 Jan 2025
1 answer
27 views
Hi team

I have this


    <Style x:Key="Style.RadTabItem.MainWindow" TargetType="{x:Type telerik:RadTabItem}">
        <!-- Base appearance -->
        <Setter Property="Background" Value="#01000000" />
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="Padding" Value="16,0" />
        <Setter Property="Margin" Value="0,0,0,0" />
        <Setter Property="MinWidth" Value="160" />
        <Setter Property="MaxWidth" Value="240" />
        <Setter Property="IsTabStop" Value="True" />
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="telerikHelpers:ThemeHelper.MouseOverBrush" Value="{DynamicResource Tab.Background.MouseOver}" />
        <Setter Property="telerikHelpers:ThemeHelper.CheckedBrush" Value="{DynamicResource Tab.Background.Selected}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type telerik:RadTabItem}">
                    <Border x:Name="OuterBorder"
                            Background="Transparent"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
                        <Grid x:Name="grd_MainTabHeader">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>

                            <Path x:Name="pth_Left"
                                  Fill="White"
                                  Data="M0,16 A16,16 0 0 0 16,0 L16,16 L0,16 Z"
                                  VerticalAlignment="Bottom"
                                  Visibility="Collapsed" />

                            <Border x:Name="MainBorder"
                                    Background="{TemplateBinding Background}"
                                    CornerRadius="8,8,0,0"
                                    Grid.Column="1"
                                    HorizontalAlignment="Stretch">
                                <Grid
                                    x:Name="grd_ContentSite"
                                    Margin="0">
                                    <Rectangle x:Name="FocusVisual" 
                                             Opacity="0"
                                             StrokeThickness="1"
                                             Stroke="Black"
                                             StrokeDashArray="1,1" />
                                    <ContentPresenter x:Name="ContentSite"
                                                    ContentSource="Header"
                                                    HorizontalAlignment="Stretch"
                                                    VerticalAlignment="Center"
                                                    Margin="{TemplateBinding Padding}" />
                                </Grid>
                            </Border>

                            <Path x:Name="pth_Right"
                                  Fill="White"
                                  Grid.Column="2"
                                  Data="M8,8 A8,8 0 0 1 0,0 L0,8 L8,8 Z"
                                  VerticalAlignment="Bottom"
                                  Visibility="Collapsed" />
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <!-- Selected state -->
                        <Trigger Property="IsSelected" Value="True">
                            <Setter TargetName="MainBorder" Property="Background" Value="White" />
                            <Setter TargetName="grd_MainTabHeader" Property="Margin" Value="-8,0,-8,0" />
                            <Setter TargetName="pth_Left" Property="Visibility" Value="Visible" />
                            <Setter TargetName="pth_Right" Property="Visibility" Value="Visible" />
                        </Trigger>

                        <!-- Mouse over state -->
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver" Value="True" />
                                <Condition Property="IsSelected" Value="False" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="MainBorder" Property="Background" Value="#e8eaed" />
                            <Setter TargetName="MainBorder" Property="CornerRadius" Value="16" />
                            <Setter TargetName="MainBorder" Property="Margin" Value="8, 0" />
                            <Setter TargetName="grd_ContentSite" Property="Margin" Value="-8, 0" />
                            
                        </MultiTrigger>

                        <!-- Focus state -->
                        <Trigger Property="IsFocused" Value="True">
                            <Setter TargetName="FocusVisual" Property="Opacity" Value="1"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

But it doesn't allow me to change selected items, as in I can't click on the tab to select it.

If I used this


<Style x:Key="Style.RadTabItem.MainWindow" TargetType="{x:Type telerik:RadTabItem}">

        <Setter Property="BorderBrush" Value="{DynamicResource Tab.Border.Selected}" />
        <Setter Property="BorderThickness" Value="0,2,0,0" />
        <Setter Property="Margin" Value="1,0" />
        <Setter Property="telerikHelpers:ThemeHelper.MouseOverBrush" Value="{DynamicResource Tab.Background.MouseOver}" />
        <Setter Property="telerikHelpers:ThemeHelper.CheckedBrush" Value="{DynamicResource Tab.Background.Selected}" />

        <Style.Triggers>
            <Trigger Property="IsSelected" Value="False">
                <Setter Property="BorderBrush" Value="Transparent" />
                <Setter Property="Background" Value="#E4E9FA" />
                <Setter Property="Margin" Value="1,0" />
            </Trigger>
        </Style.Triggers>
    </Style>

It works.

Can you help me identify what I could do to have it work?

Thanks,

H
Martin Ivanov
Telerik team
 answered on 13 Jan 2025
6 answers
392 views
Hi all,

I have a grid column and an edit field below the grid, both binding to the same property.
If that property has an invalid value (here: empty), the grid tooltip shows the error message twice.

Any chance to stop that ?




Regards,
Marco
Andrew
Top achievements
Rank 1
Iron
 answered on 10 Jan 2025
0 answers
35 views

Cells are missing content when the list grid is moved, resized, or expanded. Someone allso facing this problem?

 

JaSeen
Top achievements
Rank 1
 asked on 09 Jan 2025
1 answer
33 views

I have added a ScheduleView to my project and everything has been working fine as it has been readonly. Now I want to add an edit feature, where I want to allow the user to move the appointments, but the durations needs to be locked.

CustomDragDropBehaviour? or are there a simpler way of doing this?

I also need to apply some validation to the end f the move, and potentially highlight appointments that violate some rules. This I expect to be able to do with some standard validation methodology. Just need to trigger it when move of an appointment has completed.

Stenly
Telerik team
 answered on 06 Jan 2025
Narrow your results
Selected tags
Tags
+? more
Top users last month
Anislav
Top achievements
Rank 6
Silver
Bronze
Bronze
Jianxian
Top achievements
Rank 1
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Jim
Top achievements
Rank 2
Iron
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Anislav
Top achievements
Rank 6
Silver
Bronze
Bronze
Jianxian
Top achievements
Rank 1
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Jim
Top achievements
Rank 2
Iron
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?