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.
Hello. Please give an idea to start with ...
I have RadWatermarkTextBox. And I've added INotifyDataErrorInfo to my VM implementation.
When DisplayMode is Static - I can see validation errors. But When it's Tooltip telerik:ValidationErrorTemplateHelper.DisplayMode="ToolTip"
I can't see.
By the way. if I use static mode I also don't see red bottom border line. And red arrow at top right corner, my error text is just a black font without read rectangle around and etc.
Looks like missing styles. But I can't understand which one. I imported xaml files for Win11 style. I see that there is a definition for RadWatermarkTextBox Validation Styles.
In my `telerik:RadGridView`, I have configured a `CellValidating="RadGridView_CellValidating"` callback. It successfully catches a validation error, which then invokes this code:
e.IsValid = false;
e.ErrorMessage = "Enter a valid URL with 'https://' or 'http://'";
The cell does properly receive a red border, and what looks like a tool-tip notation in the top right corner. However, unfortunately, I am unable to see the tool-tip, regardless if I hover or click on the tool-tip. What are perhaps the top three to five reasons this might be happening?
It is specifically the "Documentation" column above, which is a `GridViewHyperlinkColumn`, which is failing validation...with no tool-tip showing. To be clear, actually none of the columns have a working or "showable" tool-tip. Even so, here is the code specifically for my "Documentation" column:
<telerik:GridViewHyperlinkColumn
IsReadOnly="{Binding IsEditModeWithPermissions, Converter={StaticResource InverseBooleanConverter}}"
CellStyle="{StaticResource GridViewCellStyleStretch}" IsCustomSortingEnabled="False"
ValidatesOnDataErrors="InViewMode"
UniqueName="Documentation"
MinWidth="80" MaxWidth="350" Width="150"
DataMemberBinding="{Binding Documentation}"
Name="DocumentationColumn" Header="Documentation">
<telerik:GridViewHyperlinkColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding DocumentationFormatted, StringFormat='{}{0}'}"/>
</DataTemplate>
</telerik:GridViewHyperlinkColumn.CellTemplate>
<telerik:GridViewHyperlinkColumn.CellEditTemplate>
<DataTemplate>
<telerik:RadComboBox x:Name="DocumentationBox"
Text="{Binding Documentation, Mode=TwoWay}" KeyDown="RadComboBox_PreviewKeyDown"
IsTextSearchEnabled="True" TextSearchMode="StartsWith" OpenDropDownOnFocus="True"
StaysOpenOnEdit="False" Loaded="RadComboBox_Loaded" IsEditable="True" >
<telerik:RadComboBox.Resources>
<Style TargetType="TextBox">
<Setter Property="MaxLength" Value="{Binding DocumentationColumnWidth}" />
</Style>
</telerik:RadComboBox.Resources>
</telerik:RadComboBox>
</DataTemplate>
</telerik:GridViewHyperlinkColumn.CellEditTemplate>
</telerik:GridViewHyperlinkColumn>
And here is the RadGridView initial declaration:
<telerik:RadGridView Grid.Row="1"
CellValidating="RadGridView_CellValidating"
BorderThickness="{Binding GridBorderThickness}"
SelectedItem="{Binding SelectedLineItem, Mode=TwoWay}" Pasting="UxGrid_OnPasting"
SelectionChanged="UxGrid_OnSelectionChanged" CopyingCellClipboardContent="UxGrid_OnCopyingCellClipboardContent"
RowIndicatorVisibility="Visible"
ValidatesOnDataErrors="InViewMode"
EditTriggers="CellClick"
ActionOnLostFocus="CommitEdit" Name="uxGrid"
PreparingCellForEdit="uxGrid_PreparingCellForEdit" Deleted="UxGrid_OnDeleted"
CellEditEnded="uxGrid_CellEditEnded"
KeyDown="GridKeyDown"
ScrollMode="Deferred"
IsReadOnly="{Binding IsGridEditable, Converter={StaticResource InverseBooleanConverter}}"
CanUserDeleteRows="{Binding CanEditNotReleased}" CanUserInsertRows="False"
AreRowDetailsFrozen="True" EnableColumnVirtualization="False"
RowDetailsVisibilityMode="{Binding RowDetailsVisibility}"
DataLoaded="UxGrid_OnDataLoaded"
RowEditEnded="RadGridViewRowEditEnded" BeginningEdit="RadGridViewBeginningEdit"
AlternationCount="2" AutoGenerateColumns="False"
ItemsSource="{Binding LineItemsView, UpdateSourceTrigger=PropertyChanged}" SourceUpdated="uxGrid_SourceUpdated_1"
Loaded="uxGrid_Loaded"
LoadingRowDetails="UxGrid_OnLoadingRowDetails"
ColumnWidthChanged="GridViewDataControl_OnColumnWidthChanged"
DataContext="{Binding}"
ColumnReordering="uxGrid_ColumnReordering"
CanUserSortColumns="{Binding IsEditMode, Converter={StaticResource InverseBooleanConverter}}"
IsFilteringAllowed="{Binding IsEditMode, Converter={StaticResource InverseBooleanConverter}}">
Hello, everyone,
I found different acts of ToolTip in different computers, the tooltip will drift to the left a little in some computers. Do you have any clue about the reason? How can we solve this? Is there any configuration of computer system we should adjust?
Is there a
telerik:ComboBoxToolTipHelper.ShowToolTipOnTrimmedText="True" that works on the RadListBox (not only the RadComboBox)?
So a :ComboBoxToolTipHelper.ShowToolTipOnTrimmedText that works on the RadListBox?
Or another way of achieving it on the RadListBox?
Background:
I tried with a behavior on the row data template but it conflicts with the drag and drop by causing exceptions during the drag and drop (but that would incur another question thread). I am just writing this to say i tried this avenue.
Right now my RadLitBox looks as follows:
<telerik:RadListBox x:Name="RLB_Source"
VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
ItemsSource="{Binding SourceSplitList, Mode=TwoWay}"
SelectionMode="Multiple"
telerik:ListBoxSelectedItemsBehavior.SelectedItemsSource="{Binding SelectedSourceItems}"
DisplayMemberPath="Name"
AllowDrop="True"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ScrollViewer.VerticalScrollBarVisibility="Visible"
Style="{StaticResource RadListBoxStyle}"
telerik:ComboBoxToolTipHelper.ShowToolTipOnTrimmedText="True"
ToolTipService.ToolTip="{Binding Text, RelativeSource={RelativeSource Self}}"
>
Because of the lines:
telerik:ComboBoxToolTipHelper.ShowToolTipOnTrimmedText="True"
ToolTipService.ToolTip="{Binding Text, RelativeSource={RelativeSource Self}}"
There is a tool tip showing the text of every RadListBox row - and not only where the text is trimmed.
How is the text trimmed? Short answer: i have a telerik:RadListBoxItem style template where text trimming is set as below:
<Setter Property="TextTrimming" Value="CharacterEllipsis"></Setter>
Here is the entire control template:
<ControlTemplate TargetType="{x:Type telerik:RadListBoxItem}">
<Border
x:Name="Bd"
Padding="{TemplateBinding Padding}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
SnapsToDevicePixels="true">
<ContentPresenter
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
>
<ContentPresenter.Resources>
<Style TargetType="TextBlock">
<Setter Property="TextTrimming" Value="CharacterEllipsis"></Setter>
<Setter Property="TextWrapping" Value="NoWrap" />
<Setter Property="Text" Value="{Binding Name}" />
<Setter Property="ToolTipService.ToolTip" Value="{Binding Name}" />
</Style>
</ContentPresenter.Resources>
</ContentPresenter>
</Border>
</ControlTemplate>
Trimming is set on the TextBlock that appears (implicitly by Telerik) in the Contentpresenter.
The whole styling is below if relevant for answering the question:
My RadListBox has this style:
<Style x:Key="RadListBoxStyle" TargetType="{x:Type telerik:RadListBox}">
<Setter Property="AlternationCount" Value="2" />
<Setter Property="ScrollViewer.CanContentScroll" Value="True" />
<Setter Property="VirtualizingPanel.ScrollUnit" Value="Pixel" />
<Setter Property="VirtualizingPanel.VirtualizationMode" Value="Recycling" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="BorderBrush" Value="{StaticResource Gray}" />
<Setter Property="Background" Value="{DynamicResource White}" />
<Setter Property="SelectionMode" Value="Multiple" />
<Setter Property="FontSize" Value="12pt" />
<Setter Property="FontFamily" Value="{StaticResource SourceSansPro-Regular}" />
<Setter Property="Foreground" Value="{StaticResource Brand Default}" />
<Setter Property="Margin" Value="0,2,0,0" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="ItemContainerStyle" Value="{StaticResource DefaultDragDropRadListBoxItemStyle}" />
</Style>
In the the above style there is an ItemContainerStyle. Here it goes:
<Style x:Key="DefaultDragDropRadListBoxItemStyle" TargetType="telerik:RadListBoxItem">
<Setter Property="BorderBrush" Value="{StaticResource 'Gray Light'}" />
<Setter Property="BorderThickness" Value="0,0,0,1" />
<Setter Property="telerik:DragDropManager.AllowCapturedDrag" Value="True" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type telerik:RadListBoxItem}">
<Border
x:Name="Bd"
Padding="{TemplateBinding Padding}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
SnapsToDevicePixels="true">
<ContentPresenter
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
>
<ContentPresenter.Resources>
<Style TargetType="TextBlock">
<Setter Property="TextTrimming" Value="CharacterEllipsis"></Setter>
<Setter Property="TextWrapping" Value="NoWrap" />
<Setter Property="Text" Value="{Binding Name}" />
<Setter Property="ToolTipService.ToolTip" Value="{Binding Name}" />
</Style>
</ContentPresenter.Resources>
</ContentPresenter>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="Bd" Property="TextElement.Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
</Trigger>
<Trigger Property="ItemsControl.AlternationIndex" Value="0">
<Setter Property="Background" Value="White"></Setter>
</Trigger>
<Trigger Property="ItemsControl.AlternationIndex" Value="1">
<Setter Property="Background" Value="{StaticResource 'Gray Lighter'}"></Setter>
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsSelected" Value="False" />
<Condition Property="IsMouseOver" Value="True" />
<Condition Property="IsKeyboardFocused" Value="False" />
</MultiTrigger.Conditions>
<Setter TargetName="Bd" Property="Background" Value="{StaticResource Brand Light}" />
</MultiTrigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsSelected" Value="False" />
<Condition Property="IsMouseOver" Value="False" />
<Condition Property="IsKeyboardFocused" Value="True" />
</MultiTrigger.Conditions>
<Setter TargetName="Bd" Property="Background" Value="{StaticResource Brand Secondary}" />
</MultiTrigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsSelected" Value="True" />
<Condition Property="IsMouseOver" Value="False" />
<Condition Property="IsKeyboardFocused" Value="True" />
</MultiTrigger.Conditions>
<Setter TargetName="Bd" Property="Background" Value="{StaticResource Brand Secondary}" />
<Setter Property="Foreground" Value="White" />
</MultiTrigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsSelected" Value="True" />
<Condition Property="IsMouseOver" Value="True" />
</MultiTrigger.Conditions>
<Setter TargetName="Bd" Property="Background" Value="{StaticResource Brand Secondary}" />
<Setter Property="Foreground" Value="White" />
</MultiTrigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsSelected" Value="True" />
<Condition Property="IsMouseOver" Value="False" />
<Condition Property="IsKeyboardFocused" Value="False" />
</MultiTrigger.Conditions>
<Setter TargetName="Bd" Property="Background" Value="{StaticResource Brand Secondary}" />
<Setter Property="Foreground" Value="White" />
</MultiTrigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsSelected" Value="False" />
<Condition Property="IsMouseOver" Value="True" />
<Condition Property="IsKeyboardFocused" Value="True" />
</MultiTrigger.Conditions>
<Setter TargetName="Bd" Property="Background" Value="{StaticResource Brand Secondary}" />
</MultiTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Good day! Which template is responsible for tooltip while dragging or resizing task? Can we customize this object?
Thank You for answers
Hi, trying to speed up the points-plot (around 1000-5000 points)
I can so far conclude that we can only get a tooltip for XamlRenderOptions DefaultVisualsRenderMode="Separate" otw, no tooltip is visible.
I have tried a few options (see below) - but maybe the behavior changes once I change the render mode ?
- XamlRenderOptions DefaultVisualsRenderMode="Batch" -> no tooltip
- (geometrytype not supported by scatterpointseries)
- BitmapRenderOptions -> no tooltip
- Direct2DRenderOptions -> not tooltip
Hi,
I observed that when the tooltip disappears, I need to move out of control before I can see the tooltip again (also in your sample with England map you can see this effect). It is reasonable, but I have a control that display a histogram plot. I could move the mouse over different bar and I would like that the tooltip could show again.
Is there a way to reactivate tooltip without exit from control?
Thank you
Luigi
Hello.
When using the tooltip content separately, the namespace is shown together.
<
telerik:RadButton
Height
=
"30"
Width
=
"30"
telerik:RadToolTipService.Placement
=
"Mouse"
telerik:RadToolTipService.ShowDuration
=
"5000"
>
<
telerik:RadButton.Content
>
<
TextBlock
Text
=
""
FontFamily
=
"Segoe MDL2 Assets"
/>
</
telerik:RadButton.Content
>
<
telerik:RadToolTipService.ToolTipContent
>
<
telerik:RadToolTipContentView
>
<
TextBlock
Text
=
"ToolTip Name"
/>
</
telerik:RadToolTipContentView
>
</
telerik:RadToolTipService.ToolTipContent
>
</
telerik:RadButton
>
If I use telerik:RadToolTipService.ToolTipContent="Content" it looks correct.
However, the above source was selected because it should be different from the button font setting.
When telerik:RadToolTipContentView is deleted, only other namespaces are shown, textblock content is not.
Please check.
Thanks.