silverlight3中的切换按钮 [英] toggle button in silverlight3

查看:77
本文介绍了silverlight3中的切换按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用c#编写项目,并在silverlight3中进行设计..

我有三个切换按钮:粗体",斜体",下划线"


我已经完成了粗体和斜体的编码


void _btnBold1_Click(对象发送者,RoutedEventArgs e)
{
试试
{
如果(_btnBold1.IsChecked.HasValue)
{
txtMailBody1.Selection.FontWeight = _btnBold1.IsChecked.Value吗? FontWeights.Bold:FontWeights.Normal;
}
}
catch(ex ex例外)
{
MessageBox.Show(ex.Message);
}
}


void _btnItalics1_Click(对象发送者,RoutedEventArgs e)
{
试试
{
如果(_btnItalics1.IsChecked.HasValue)
{
txtMailBody1.Selection.FontStyle = _btnItalics1.IsChecked.Value吗? FontStyles.Italic:FontStyles.Normal;
}
}
catch(ex ex例外)
{
MessageBox.Show(ex.Message);
}
}







但是不知道下划线需要什么编码....



void _btnUnderline_Click(对象发送者,RoutedEventArgs e)
{
如果(_btnUnderline.IsChecked.HasValue)
{

}
}

I am making the project as coding in c# and designing in silverlight3..

I have three toggle button "bold" , "Italics" , "underline"


I have done the coding for bold and italics


void _btnBold1_Click(object sender, RoutedEventArgs e)
{
try
{
if (_btnBold1.IsChecked.HasValue)
{
txtMailBody1.Selection.FontWeight = _btnBold1.IsChecked.Value ? FontWeights.Bold : FontWeights.Normal;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}


void _btnItalics1_Click(object sender, RoutedEventArgs e)
{
try
{
if (_btnItalics1.IsChecked.HasValue)
{
txtMailBody1.Selection.FontStyle = _btnItalics1.IsChecked.Value ? FontStyles.Italic : FontStyles.Normal;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}







but In don''t know what coding is required for underline....



void _btnUnderline_Click(object sender, RoutedEventArgs e)
{
if (_btnUnderline.IsChecked.HasValue)
{

}
}

推荐答案

尝试使用-
txtMailBody1.TextDecorations=TextDecorations.Underline;
Try using something like -
txtMailBody1.TextDecorations=TextDecorations.Underline;


如果这是组件一个富文本框-请查看其文档
If this is the Component one rich text box - have a look at their documentation here.

They provide the following solution.
You need to do the same

private void _btnUnderline_Click(object sender, RoutedEventArgs e)
{
bool underline = _rtb.Selection.TextDecorations ==
TextDecorations.Underline;
_rtb.Selection.TextDecorations = underline
? null
: TextDecorations.Underline;
}



您的代码将如下所示-txtMailBody1.Selection.TextDecorations == TextDecoration.Underline;



Your code will be something like this - txtMailBody1.Selection.TextDecorations == TextDecoration.Underline;


这篇关于silverlight3中的切换按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆