XAML的样式错误 [英] Styling Error for XAML

查看:161
本文介绍了XAML的样式错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 

< Page x:Class =" ScribbleNotes.scribblenotesdates"  &NBSP; &NBSP;

的xmlns = QUOT; HTTP://schemas.microsoft.com/winfx/2006/xaml/presentation"&NBSP; &NBSP; &NBSP;

的xmlns:X =" HTTP://schemas.microsoft.com/winfx/2006/xaml"&NBSP; &NBSP; &NBSP;

的xmlns:MC = QUOT; HTTP://schemas.openxmlformats.org/markup-compatibility/2006"&NBSP;&NBSP; &NBSP; &NBSP;

的xmlns:d =" HTTP://schemas.microsoft.com/expression/blend/2008"&NBSP;&NBSP; &NBSP; &NBSP;

的xmlns:本地= QUOT; CLR-名称空间:ScribbleNotes"&NBSP; &NBSP; &NBSP;

MC:可忽略= QUOT; d"&NBSP;&NBSP; &NBSP; &NBSP;

d:DesignHeight = QUOT; 450" d:DesignWidth = QUOT; 800"&NBSP; &NBSP; &NBSP;

Title =" scribblenotes-注明日期>


这是Xaml表格的前部。 



$
 



 这是XAML表格
< pre class ="prettyprint">

  &NBSP; <! - 注意日期 - >  &NBSP; &NBSP;

< StackPanel Grid.Column =" 0" Grid.ColumnSpan = QUOT; 2英寸Grid.Row = QUOT 1 QUOT;&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;

取向= QUOT;水平" />&NBSP; &NBSP; &NBSP;

< Grid Grid.Column =" 0" Grid.ColumnSpan = QUOT; 2英寸Grid.Row = QUOT; 2英寸VerticalAlignment = QUOT;顶部和QUOT;&NBSP;&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;

的Horizo​​ntalAlignment = QUOT;左">&NBSP; &NBSP; &NBSP; &NBSP;

<! - 注意页面和注意目的 - >  &NBSP; &NBSP; &NBSP;

< DataGrid ColumnHeaderStyle =" {StaticResource columnHeaderStyle}"  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;

的AutoGenerateColumns = QUOT假QUOT; RowHeaderWidth = QUOT; 0"余量= QUOT; 330,49,-330,-49" >&NBSP;&NBSP;&NBSP; &NBSP; &NBSP;

< Label Style =" {StaticResource labelStyle}"内容="发布的月份" Grid.Column = QUOT 1 QUOT;余量= QUOT; 75,84,56,268"

Grid.Row = QUOT; 2英寸/>&NBSP; &NBSP; &NBSP;

< TextBlock Grid.Column =" 1"余量= QUOT; 84,19,96,353" Grid.Row =" 2">< Run Text =" Note of Category:" />< / TextBlock>  &NBSP; &NBSP;

< Label Style =" {StaticResource labelStyle}"内容="发布日期" Grid.Column = QUOT 1 QUOT;余量= QUOT; 81,106,65,246"

Grid.Row = QUOT; 2英寸/>&NBSP; &NBSP; &NBSP;

< Label Style =" {StaticResource labelStyle}"内容="发布的注释年份" Grid.Column = QUOT 1 QUOT;

保证金= QUOT; 79,150,65,228" Grid.Row =" 2" />




我正在研究如何解决标签样式    {staticResource labelStyle}。它应该使标签样式独特。但是它使标签,列样式或headerTextStyle无法解析。 
$



WPF文件格式的XAML代码

" < Label Style =" {StaticResource labelStyle}">已发布的注释年份< / Label>

< Label Style =" {StaticResource labelStyle}">发布的月份< / Label>

< Label Style =" {StaticResource labelStyle}">发布日期< / Label>"



我无法为此标签,列标题样式,headerTextStyle和其他部分解析我的标签样式静态资源。



您可以为此查找静态资源和WPF文件设计。 

这是一个旨在拥有的WPF文件wpf项目中标签和其他行或列功能的样式。 



非常感谢您的帮助!


 


解决方案

嗨    Caleb Yang,



>>我正在研究如何解决标签样式    {staticResource labelStyle}。它应该使标签样式独特。但是它会使标签,列样式或headerTextStyle
无法解析。 




您需要为您的标签定义一个通用样式资源。



您可以在Application.Resources中定义样式,它将应用于整个应用程序,而不管其他定义是什么。这将允许全局应用程序范围的样式,如字体,文本大小,颜色等。



例如:labelStyle 

< Application.Resources> 
< Style x:Key =" labelStyle" TargetType =" {x:Type Label}">
< Setter Property =" Height"值= QUOT; 53" />
< Setter Property =" Width"值= QUOT; 80 QUOT; />
< Setter Property =" Horizo​​ntalAlignment"值= QUOT;左" />
< Setter Property =" Margin"值= QUOT; 99,71,0,0" />
< Setter Property =" VerticalAlignment"值="顶部" />
< Setter Property =" Foreground"值= QUOT;#FFE75959" />
< Setter Property =" FontFamily"值= QUOT;宋体" />
< Setter Property =" FontSize"值= QUOT; 40" />
< / Style>
< /Application.Resources>








以下链接供您参考。



一天掌握WPF DataGrid:第3小时DataGrid标题

https://www.c-sharpcorner .com / UploadFile / mahesh / master-wpf-datagrid-in-24-hrs-hour-3-datagrid-header /



$ b $
最好的问候



Yong Lu




 


<Page x:Class="ScribbleNotes.scribblenotesdates"     

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"     

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"     

xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"      

xmlns:d="http://schemas.microsoft.com/expression/blend/2008"      

xmlns:local="clr-namespace:ScribbleNotes"     

mc:Ignorable="d"      

d:DesignHeight="450" d:DesignWidth="800"     

Title="scribblenotes- Date of Note">

This is the front part of the Xaml Form. 


 

 This is in XAML Form

    <!-- Note Date -->     

<StackPanel Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="1"                 

Orientation="Horizontal"/>     

<Grid Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="2" VerticalAlignment="Top"            

HorizontalAlignment="Left">       

<!-- Pages of Note and Purpose of Note -->       

<DataGrid ColumnHeaderStyle="{StaticResource columnHeaderStyle}"                 

AutoGenerateColumns="False" RowHeaderWidth="0" Margin="330,49,-330,-49" >       

<Label Style="{StaticResource labelStyle}" Content="Month of Note Published" Grid.Column="1" Margin="75,84,56,268"

Grid.Row="2"/>     

<TextBlock Grid.Column="1" Margin="84,19,96,353" Grid.Row="2"><Run Text="Category of Note:"/></TextBlock>     

<Label Style="{StaticResource labelStyle}" Content="Day of Note Published" Grid.Column="1" Margin="81,106,65,246"

Grid.Row="2"/>     

<Label Style="{StaticResource labelStyle}" Content="Year of Note Published" Grid.Column="1"

Margin="79,150,65,228" Grid.Row="2"/>


I am looking into how to resolve the label style   {staticResource labelStyle}. It is supposed to make the label style unique. However it makes the label, column style or the headerTextStyle unresolvable. 

XAML Code in WPF File Format
" <Label Style="{StaticResource labelStyle}"> Year of Note Published </Label>
<Label Style="{StaticResource labelStyle}"> Month of Note Published</Label>
<Label Style="{StaticResource labelStyle}"> Day of Note Published </Label>"

I am unable to resolve my labelstyle for static resource for this label, column header styles, headerTextStyle and other parts.

You can look up the Static Resources and WPF file design for this. 
It is a WPF file that is designed to have a styling for the labels and other row or column features in the wpf project. 

Thanks a lot for your help!

 

解决方案

Hi   Caleb Yang,

>>I am looking into how to resolve the label style   {staticResource labelStyle}. It is supposed to make the label style unique. However it makes the label, column style or the headerTextStyle unresolvable. 

You need to define a a generic style resources for your labels.

You can define the styles in Application.Resources and it will apply to the entire application regardless of what other definitions exist. This will allow for global application-wide styling, such as font, text sizes, colors, etc.

For example: labelStyle 

 <Application.Resources>
        <Style x:Key="labelStyle" TargetType="{x:Type Label}">
            <Setter Property="Height" Value="53" />
            <Setter Property="Width" Value="80" />
            <Setter Property="HorizontalAlignment" Value="Left" />
            <Setter Property="Margin" Value="99,71,0,0" />
            <Setter Property="VerticalAlignment" Value= "Top" />
            <Setter Property="Foreground" Value="#FFE75959" />
            <Setter Property="FontFamily" Value="Calibri" />
            <Setter Property="FontSize" Value="40" />
        </Style>
    </Application.Resources>



The following links for your reference.

Mastering WPF DataGrid in a Day: Hour 3 DataGrid Header
https://www.c-sharpcorner.com/UploadFile/mahesh/master-wpf-datagrid-in-24-hrs-hour-3-datagrid-header/


Best Regards

Yong Lu

 


这篇关于XAML的样式错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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