This is a migrated thread and some comments may be shown as answers.

Editor Window ShowDialog Error.

7 Answers 503 Views
ColorEditor
This is a migrated thread and some comments may be shown as answers.
Psyduck
Top achievements
Rank 5
Bronze
Bronze
Bronze
Psyduck asked on 02 Apr 2021, 11:51 AM

Hello

I created the Editor after watching the demo.

When an error occurs, clicking the button first opens the Editor window, but an error occurs.

-------This Error-------------

System.Windows.Markup.XamlParseException: ''Cannot set unknown member 'System.Windows.Controls.TextBox.IsReadOnly'.'

Line number '1301' and line position '21'.'

------------------------

There is no content of Editor Xaml. 

There is no error when creating an instance. Error appears when using ShowDialog!

 

 

var window = new EditorView(); // Pass

window.showdialog(); // <<  Error

 

    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/KickOff;component/Resources/NoXaml/NoXamlTemplate.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Window.Resources>
 
    <Grid>
        <telerik:RadColorEditor x:Name="radColorEditor" />
        <StackPanel Orientation="Horizontal" VerticalAlignment="Bottom" HorizontalAlignment="Right"
                    Height="32" Margin="0 0 11 11">
            <Button Content="OK" Width="60" Margin="0 0 10 0"
                    Click="OnClickOkCommand"  => Using DialogResult = true, Close()
                    />
            <Button Content="Cancel"  Width="60"
                    Click="OnClickCancelCommand"  => Using DialogResult = false, Close()
                    />
        </StackPanel>
    </Grid>

 

I used telerik noxaml version 2021_1_308, office 2019 themes.

refer : telerik controls, controls.input 

themes.implicit wpf40 office2019 : system.windows.xaml, telerik.controls.xaml, telerik.controls.input.xaml

 

Thanks.

7 Answers, 1 is accepted

Sort by
0
Psyduck
Top achievements
Rank 5
Bronze
Bronze
Bronze
answered on 02 Apr 2021, 11:56 AM

I found a solution.

There is an error only in office2019.

When I ran it on Windows7, Fluent Themes, it worked fine.

 

But I want to use office2019. Will it be resolved?

Thanks.

0
Vicky
Telerik team
answered on 05 Apr 2021, 04:21 PM

Hi KIM,

Thanks for the provided information and code snippets.

Based on the above, I tried to replicate the described behavior, but to no avail. Would it be possible for you to send over a runnable sample project which demonstrates the behavior, so that I could better assist you?

I am looking forward to your reply.

Regards,
Vicky
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Psyduck
Top achievements
Rank 5
Bronze
Bronze
Bronze
answered on 06 Apr 2021, 01:51 AM

Hello.

 

I tried making a sample project and it works fine.

All were the same conditions, the only difference is that my program runs inside an external program.

 

Does it affect you? In fact, in the case of a dll, you have to put it in an external program and manually assemble the dll.

What a strange thing.

Post the error image. This seems to be an ambiguous solution.

 

Thanks.

0
Vicky
Telerik team
answered on 06 Apr 2021, 07:14 AM

Hello,

I did some research and it appears that attempting to parse the XAML using XamlReader.Parse() may lead to such exceptions. Or attempting to load XAML using the  XamlReader.Load() method. If the TextBox's IsReadOnly property is not set, the parser will manage to do its work. It will also parse just fine if the same property is set in a style trigger and you remove this trigger.

If this is your case, there are several things that you can try in order to avoid it:

  • If the IsReadOnly property is set in a style trigger, change the "True" with:
    xmlns:s="clr-namespace:System;assembly=mscorlib"
    
    <s:Boolean x:Key="BooleanTrue">True</s:Boolean>
    <Style TargetType="TextBox">
        <Style.Triggers>
            <Trigger Property="IsReadOnly" Value="{StaticResource BooleanTrue}">
                <Setter Property="Background" Value="#FFEEEEEE" />
             </Trigger>
        </Style.Triggers>
    </Style>
  • If the Text property of this TextBox is set to a binding and + the IsReadOnly property is set to True, set the binding Mode to OneWay:
    <TextBox Text="{Binding SomeProperty, Mode=OneWay}" IsReadOnly="True" />
  • Also, when using implicit styles (like in your case), try to configure the respective XAML files with build action of "Page" if they were configured as a "Resource".

Keep in mind that all of the above is applicable for scenarios where the respective TextBox instance comes from your app and not the external one.
Please, try out the suggestions and let me know if you found them helpful.

Best Regards,
Vicky
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Psyduck
Top achievements
Rank 5
Bronze
Bronze
Bronze
answered on 06 Apr 2021, 07:42 AM

Hello.

 

I have read and tried your suggestions. It was interesting.

As a result, the second method you suggested works.

My environment is like this.

"System.Windows.xaml", "Telerik.Windows.Controls.Data.xaml",

"Telerik.Windows.Controls.Input.xaml", "Telerik.Windows.Controls.xaml"

Here I set all the build properties are "Resource".

If only Telerik.Windows.Controls.Input.xaml changes "Page", it works normally.

If you change Telerik.Windows.Controls.Data.xaml to "Page", the build fails.

Other than that, it doesn't matter.

That said, here I am curious. Is there a difference between Page and Resource for build work?

I basically change Page to Resource when loaded.

 

And it tells me about the first proposal.

I have never used a TextBox in that source. Only TextBlock was used. So I still get the error.

If it is a problem with TextBox, it is judged that it belongs to TextBox, which is a function of RadColorEditor itself.

 

Thank you for doing the research and letting me know.

0
Psyduck
Top achievements
Rank 5
Bronze
Bronze
Bronze
answered on 06 Apr 2021, 08:00 AM

Oops. Sorry

 

I can't edit the post, so I write a comment.

Error in Bulid Action is my mistake!

 

Is there a difference between Resouce and Page in Build Action?

I've been working on Resource so far.

 

1
Accepted
Vicky
Telerik team
answered on 07 Apr 2021, 10:54 AM

Hi KIM,

By default, WPF sets Page as a Build Action to any XAML file. Is there a reason for setting WPF XAML files to Resource? I wouldn't recommend you to change the default Build Action of Page unless you have a reason to do so.

I managed to reproduce the error by changing the build action of the Telerik theme resource dictionaries to Resource or Content. Our RadComboBox (which is part of the RadColorEditor) and some other controls from the Input assembly use a TextBox internally in their default control templates and its ReadOnly property appears to produce the error when the Build Action is different than the default one (Page).

More information about the different Build Actions can be found at Microsoft's Build actions documentation article.
I hope you find the above information helpful. Let me know if there is anything else I can assist you with.

Best Regards,
Vicky
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
ColorEditor
Asked by
Psyduck
Top achievements
Rank 5
Bronze
Bronze
Bronze
Answers by
Psyduck
Top achievements
Rank 5
Bronze
Bronze
Bronze
Vicky
Telerik team
Share this question
or