Telerik Forums
UI for WPF Forum
1 answer
22 views
Hi all

I have tried all sorts of ways (BindingProxy, Converters, DP Helpers..) but I can't seem to get it to work.

I have this:

  <telerik:GridViewDataColumn
      Header="Unit Cost"
      DataMemberBinding="{Binding UnitCost}"
      Style="{StaticResource Style.GridViewDataColumn.Currency}"
      Width="120" />

And the style (simplified) is this:

<Style
    x:Key="Style.GridViewDataColumn.Currency"
    TargetType="{x:Type telerik:GridViewDataColumn}">
    <Setter
        Property="DataFormatString"
        Value="N2" />

    <!-- Cell Template (Display Mode) -->
    <Setter
        Property="CellTemplate">
        <Setter.Value>
            <DataTemplate>
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition
                            Width="Auto" />
                        <ColumnDefinition
                            Width="*" />
                    </Grid.ColumnDefinitions>
                    <TextBlock
                        Text="$"
                        VerticalAlignment="Center"
                        Margin="5,0" />
                    <TextBlock
                        Text="{Binding ??, StringFormat=N2}"
                        VerticalAlignment="Center"
                        HorizontalAlignment="Right"
                        Grid.Column="1" />
                </Grid>
            </DataTemplate>
        </Setter.Value>
    </Setter>

    <!-- Cell Edit Template -->
    <Setter
        Property="CellEditTemplate">
        <Setter.Value>
            <DataTemplate>
                <telerik:RadMaskedCurrencyInput
                    Value="{Binding Path=??, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                    IsTabStop="True" />
            </DataTemplate>
        </Setter.Value>
    </Setter>
</Style>

How can I define the Path generically. If I hard code UnitCost it works, but I need it to be generic, and I can't find a way to do it.

PS: Design breif is that our company wants to display the $ sign on the left and the value aligned right.

Any insight would be welcomed greatly.
Stenly
Telerik team
 answered on 04 Mar 2025
1 answer
32 views

Hello,

in the "Installing License Key" guide it is specified the license key is personal. But in the "Adding the License Key to CI/CD Services" section it is suggested to create an environment variable to store the license key value. Now because the CD/CD platform in my company is located in cloud and it is shared between all the developers I suppose we need to ask to one of our developers to share with everybody else his personal license key in order to set it as an environment variable in cloud. In my opinion this use case reveals a sort of mismatch in the usage of license key as a "personal".  Is there a way to avoid to use a personal license key as a environment variable?

Thanks,

Alcide

 

 

Martin Ivanov
Telerik team
 answered on 03 Mar 2025
3 answers
1.0K+ views

Hi, 

I have some struggle with context menu binding. The problem is that I cant bind Command from  CustomerViewModel  to a RadMenuItem in a Context menu.

Here is my code:

public class CustomerViewModel : ViewModelBase
{
    private ObservableCollection<Customer> _customers;
 
    public ICommand AddCom { get; set; }
    public ICommand DelCom { get; set; }
    public CustomerViewModel()
    {
        AddCom = new DelegateCommand(Add);
        DelCom = new DelegateCommand(Del);
    }
 
    private void Add(object o)
    {
        Customers.Add(new Customer(){Id=Customers.Count,
                Name="Customer "+ Customers.Count.ToString()} );
        OnPropertyChanged(() => this.Customers);
    }
    private void Del(object o)
    {
        Customers.Remove((Customer) o);
        OnPropertyChanged(() => this.Customers);
    }
     
    public ObservableCollection<Customer> Customers
    {
        get => this._customers;
        set
        {
            if (this._customers == value) return;
            this._customers = value;
            this.OnPropertyChanged(() => this.Customers);
        }
    }
}

and XAML

<Window x:Class="CustomListBoxDragDropBehavior.MainWindow"
        xmlns:local="clr-namespace:CustomListBoxDragDropBehavior"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"
        Title="MainWindow" Height="350" Width="525" >
    <d:Window.DataContext>
        <local:CustomerViewModel/>
    </d:Window.DataContext>
    <Window.Resources>
        <telerik:RadContextMenu x:Key="Menu">
            <telerik:RadMenuItem Header="Add customer" Command="{Binding ??? }" />
            <telerik:RadMenuItem Header="Remove customer" Command="{Binding ???}"
                   CommandParameter=" ??? "/>/>
        </telerik:RadContextMenu>
        <Style x:Key="ListBoxItem" TargetType="telerik:RadListBoxItem">
            <Setter Property="telerik:RadContextMenu.ContextMenu" Value="{StaticResource Menu}"/>
        </Style>
    </Window.Resources>
 
    <Grid >
        <telerik:RadListBox ItemContainerStyle="{StaticResource ListBoxItem}"
                            ItemsSource="{Binding Customers, Mode=TwoWay}"
                            DisplayMemberPath="Name"
                            >
        </telerik:RadListBox>
    </Grid>
</Window>

I tried few combination like 

<telerik:RadMenuItem Header="Item" Command="{Binding RelativeSource={RelativeSource AncestorType={x:Type Window}}, Path=DataContext.AddCom }" />

with no success. Also I need to pass current customer to a DelCom as parameter.

Please advise.

 

fabrizio
Top achievements
Rank 1
Iron
 updated answer on 03 Mar 2025
0 answers
21 views

Hello, 

I use the Telerik TreeListView. I would like to implement auto resizing for the header cells. In my app, there is the possibility to change the language. Some of the header texts may be changed by this action.

If a text becomes longer after changing the language (e. g. the German word "Haus" is replaced by the English word "House"), the width of the column gets bigger. That means, auto resizing to a bigger width exists..

But after changing back to German (the header content becomes shorter), there is no auto resizing to a smaller width.

Is there an event I can check or a property for the TreeListView?

Thank you very much.

Best regards,

Alex

Alexander
Top achievements
Rank 1
 asked on 28 Feb 2025
1 answer
20 views

Hi,

In my project I am working on using RichTextBox to edit HTML text. In the project I use implicit styling and the Expression Dark theme. And for everything else in the project it works fine, but I am having issues with the RichTextBox.

I have added the reference to the dll, and in App.xaml I have added the styles. I was expecting the textbox to become darker, but I can also see a bunch of errors from the styling.

Wonder what I am missing.

 

Martin Ivanov
Telerik team
 answered on 27 Feb 2025
1 answer
23 views

Hello, I would like to add a “Cartesian PlotBand Annotation” to a “CartesianChart” at runtime.
This should be done in the MVVM environment. For this I would add a list “List<CartesianPlotBandAnnotation>” as a property to my “MainViewModel”. I then fill the individual elements of this list with the corresponding data. The property “Axis” of type “CartesianAxis” must also be specified. Unfortunately, this object is not known to the “MainViewModel”. What is the solution here?

 

 

Stenly
Telerik team
 answered on 26 Feb 2025
0 answers
22 views

Hi,

As mentioned above, I would like to add a button that allows me to select which columns of the radgridview that I want to show. May I seek your advise on this?

Lim
Top achievements
Rank 1
Iron
 asked on 26 Feb 2025
0 answers
18 views

I am facing an issue while loading the docking window saved XML to load. I have cross-checked XML files and found that there is no error in xml file. But while loading into an application it will show a red color lock icon.

Secondly, additional empty tabs will be shown along with other tabs. I have attached the screeshot. In screenshot, it has fixed window. But red icon can be seen in docking window also.

There are scenarios where empty tabs will be seen in mid of multiple tabs. But data collection don't have additional records.

Amit
Top achievements
Rank 1
 asked on 25 Feb 2025
1 answer
21 views

I have a quite strange behavior for ComboBox

When I set IsReadOnly to true the ReadOnlyBorderBrush of the theme is apllied but ReadOnlyBackBrush is not, also it is not really read only value can still be changed by the user. To avoid this I have set IsReadOnly to true and IsEnabled to false in that case neither Border nor BackBrush is applied.

What am I missing here?

Here is a example 1st Combox has IsReadOnly="True" IsEnabled="False", 2nd Combox only IsReadOnly="True" and at the bottom a TextBox with only IsReadOnly="True" as reference.

Stenly
Telerik team
 answered on 24 Feb 2025
1 answer
29 views

I found out that the ReadOnlyBackgroundBrush from Theme setting is not applied in GridView.

In some grid I have a whole column that should not be edited from the User, while some grid is only editable when the user has the right to do it and some rows are ReadOnly depending on the state of the Row.

Are there theme colors that are dedicated for GridView or is there a generic way to apply a color to GridView and it's cells/rows in ReadOnly state? 

Stenly
Telerik team
 answered on 24 Feb 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?