Я пытался используйте CSS в файле xaml.cs, но он не работает. У меня есть 2 режима с кнопкой: сначала это просто цвет фона и водяной знак, а когда я нажимаю кнопку, она перемещается по элементам HTML, таким как изображения и текст. Я попробовал сделать это, как показано ниже.
Код: Выделить всё
private void LoadDefaultWebBrowserContent()
{
string defaultHtml = "" +
"" +
"html, body { height: 100%; margin: 0; padding: 0; background-color:#2C3040 !important; color: white; }" +
".watermark { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%) rotate(-45deg); font-family:'Roboto', sans-serif; font-size: 38px;" +
"color: rgba(102, 105, 117, 0.5); white-space: nowrap; pointer-events: none; }" +
"" +
"ASC-YardimPanel" +
"";
ContentWebBrowser.NavigateToString(defaultHtml);
}
Код: Выделить всё
private string ApplyHtmlStylesForDetailsWindow(string content)
{
return "" +
"" +
"html, body { height: 100%; margin: 0; padding: 0; background-color:#2C3040 !important; color: white; }" +
".watermark { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%) rotate(-45deg); font-size: 20px;" +
"color: rgba(102, 105, 117, 0.5); white-space: nowrap; pointer-events: none; }" +
"h1, h2, h3, h4, h5, h6, p, span, div {{ font-family: 'Roboto', sans-serif; font-size:12px; color: #9A9EB1 !important; }}" +
"th, td {{ font-size:12px; font-family: 'Roboto', sans-serif !important; padding: 10px; border: 1px solid white !important }}" +
"td {{ background-color: transparent !important; }}" +
"img {{ width:60%; height: 60% !important;}}" +
"" +
"ASC-YardimPanel" +
$"{content}" +
"";
Подробнее здесь: https://stackoverflow.com/questions/791 ... webbrowser