The injection control in RichTextBox in siverlight cannot be used.

Source: Internet
Author: User
Although I have been in contact with Silverlight for a while, I have very little access to RichTextBox. This time, I have a good time to access this control. I found this control is really good, in the past, only Textbox, textblock, and even text-and-text mixed la s were used. Today, RichTextBox is much easier to use, but I also found out why all the controls I injected with <inlineuicontainer> are disable. For example, if I added a button, why can't I click it? I have watched su Peng's video before. He also encountered this problem during video recording. He said it may still be due to security issues in Silverlight. But I really don't know why. No matter how isenable = "true" in the button attribute is set in XAML, it is useless. If the click event is bound in the background, I cannot click the button or trigger the click event, later, I found my solution. After loading RichTextBox, I set the isenable of the button to true. The result is okay. I saw the http://www.cnblogs.com/024hi/archive/2009/11/19/1606293.html too? Login = 1 code, why is richtextarea (I have never seen it), and he does not have a problem? Hope you can tell your younger brother. My code: view code

<RichTextBox name = "myrichtextbox">
<Paragraph>
<Run Text = ""/>
This is a simple RichTextBox. If we look at the code, we find that this is very different from the textbox and textblock we usually use,
He does not use the text attribute for text input. Instead, we can see that he is composed of a paragraph and a paragraph.
Because of the time, I didn't have a good grasp of this control, until now I found that what I did was completely completed by this RichTextBox.
</Paragraph>
<Paragraph>
<Run Text = ""/>
For example, I may want to identify several problems that I encountered at the beginning. Now I use RichTextBox to see if it can be easily solved:
</Paragraph>
<Paragraph>
<Run Text = ""/>
1) At the beginning, we could not set textblock or some text in textbox. Now let's test it. I just use
<Run Text = "<"/> RUN <run Text = ">"/>.
<Run foreground = "blue" text = "This is a blue-colored string! "/>
No. I conveniently set the blue color.
</Paragraph>
<Paragraph>
<Run Text = ""/>
2) Maybe I want to implement a mix of controls and text. In the past, textblock or textbox cannot be squashed, because they only have the text attribute, which is a string type.
But now I want to give it a try. I put a button in it. We can use
<Run Text = "<"/> inlineuicontainer
<Run Text = ">"/>
This label is implemented,
This is a button
<Inlineuicontainer>
<Button content = "button" name = "mybutton" isenabled = "true" cursor = "hand">
<Button. rendertransform>
<Translatetransform y = "4"/>
</Button. rendertransform>
</Button>
</Inlineuicontainer>
<Inlineuicontainer>
<Button content = "button" name = "mybutton2" isenabled = "true" cursor = "hand" margin = "5, 0, 0">
<Button. rendertransform>
<Translatetransform y = "4"/>
</Button. rendertransform>
</Button>
</Inlineuicontainer>
In the result, we can see this button, but we can see a very strange thing, that is, when the button status is disable, we cannot click.
This problem also appeared in Su Peng's video. Su Peng said it may be because of security issues in Silverlight. Is it true that only images can be placed?
Now I will try a linkbutton.
<Inlineuicontainer>
<Hyperlinkbutton navigateuri = "http://www.baidu.com" content = "http://www.baidu.com" isenabled = "true"/>
</Inlineuicontainer>
</Paragraph>
</RichTextBox>
The above code must be disable, and the background code that cannot be clicked: view code

 public partial class RichTextBoxDemo : Page
{
public RichTextBoxDemo()
{
InitializeComponent();


myRichTextBox.Loaded += new RoutedEventHandler(myRichTextBox_Loaded);
}

void myRichTextBox_Loaded(object sender, RoutedEventArgs e)
{
var inlineButton = (Button)myRichTextBox.FindName("myButton");
inlineButton.Click += Button_Click;
inlineButton.IsEnabled = true;
}

// Executes when the user navigates to this page.
protected override void OnNavigatedTo(NavigationEventArgs e)
{
}

private void Button_Click(object sender, RoutedEventArgs e)
{

}

}

 

(A button can be clicked, but another button that is not processed cannot be clicked)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.