Catastrophic error while setting dependency property

0

I have got problem while setting dependency property to XAML Element. XAML:

        <local2:RichTextColumns xmlns:local2="using:App2.Common">
            <local2:RichTextColumns.ColumnTemplate>
                <DataTemplate x:Name="overflowControl1">
                    <RichTextBlockOverflow Width="1000" Margin="5,0,0,0"/>
                </DataTemplate>
            </local2:RichTextColumns.ColumnTemplate>
            <RichTextBlock Foreground="Black" Width="1000">
                <Paragraph>
                </Paragraph>
            </RichTextBlock>
        </local2:RichTextColumns>

C#

var tmp = (DataTemplate)FindName("overflowControl1");
tmp.SetValue(RichTextBlockOverflow.ActualWidthProperty, 100);

It results in

Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED)).

I have also tried using RichTextBlockOverflow.WidthProperty

Thank you in advance :)

c#
xaml
windows-8
asked on Stack Overflow Aug 6, 2012 by Krzysztof Kaczor • edited Sep 29, 2016 by lokusking

2 Answers

1

try

<local2:RichTextColumns xmlns:local2="using:App2.Common">
        <local2:RichTextColumns.ColumnTemplate>
            <DataTemplate>
                <RichTextBlockOverflow  x:Name="overflowControl1" Width="1000" Margin="5,0,0,0"/>
            </DataTemplate>
        </local2:RichTextColumns.ColumnTemplate>
        <RichTextBlock Foreground="Black" Width="1000">
            <Paragraph>
            </Paragraph>
        </RichTextBlock>
    </local2:RichTextColumns>

C#

var tmp = (RichTextBlockOverflow)FindName("overflowControl1");
tmp.SetValue(RichTextBlockOverflow.WidthProperty, 100);
answered on Stack Overflow Aug 6, 2012 by S3ddi9
0

Ok Found great solution. I used binding to set same width to RichTextBlock and RichTextBlockOverflow.

answered on Stack Overflow Aug 7, 2012 by Krzysztof Kaczor

User contributions licensed under CC BY-SA 3.0