<Image Name="icon" Width="40" Height="40"  Source="/Resources/huocheS.png" />

<Border Width="210"  BorderBrush="#626363" BorderThickness="1"  Margin="5">
         <Label x:Name="lab" Foreground="#626363"  >sdf</Label>
  </Border>

<StackPanel Height="230"  x:Name="pinfo" >
            <StackPanel.Background>
                <ImageBrush ImageSource="/Resources/info.png" Opacity="0.7"></ImageBrush>
            </StackPanel.Background>
</StackPanel>

Label 设置背景色

 Label.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#626363"));
Label.BorderBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#626363"));

设置背景图片

    //tabA1.Background = new ImageBrush { ImageSource = new BitmapImage(new Uri(filepath)) };

画图形顺序为逆时针

  <Polygon  x:Name="pl1"
Points="0,0 0,30 160,30 130,0"
Stroke="Purple"
StrokeThickness="0">
<Polygon.Fill>
<SolidColorBrush Color="#126CB1"/> </Polygon.Fill>
</Polygon>

后台修改所画的图形位置

  private void Removestate(Polygon path, TextBlock label)
{
if (path.Points[0].Y == 0)
{
path.Points[0] = new Point(path.Points[0].X + 10, path.Points[0].Y + 10);
path.Points[1] = new Point(path.Points[1].X + 10, path.Points[1].Y + 10);
path.Points[2] = new Point(path.Points[2].X + 10, path.Points[2].Y + 10);
path.Points[3] = new Point(path.Points[3].X + 10, path.Points[3].Y + 10);
Canvas.SetTop(label, Canvas.GetTop(label) + 10);
Canvas.SetLeft(label, Canvas.GetLeft(label) + 10);
path.Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#547EAD"));
} }

Image 绑定

image1.Source = new BitmapImage(new Uri(filepath + "Resources\\images\\map2.png"));

RichTextBox定时刷新添加内容

delegate void mydelete();
private void bindRichText()
{
try
{
DispatcherTimer dTimer = new System.Windows.Threading.DispatcherTimer(); dTimer.Tick += new EventHandler(dTimer_Tick);
dTimer.Interval = new TimeSpan(0, 0, 0, 0, 1000); string filepath = Environment.CurrentDirectory;
if (filepath.Substring(filepath.Length - 1) != "/")
filepath += "\\" + "DataFile\\" + "rich1.txt";
StreamReader sr = new StreamReader(filepath, Encoding.Default);
allinfo = new List<string>();
string rowinfo = "";
while (!string.IsNullOrEmpty(rowinfo = sr.ReadLine()))
{
allinfo.Add(rowinfo);
}
sr.Close();
sr.Dispose();
setText();
dTimer.Start();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
void dTimer_Tick(object sender, EventArgs e)
{
try
{
mydelete dele = new mydelete(setText);
dele.Invoke();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
} private void setText()
{
if (i == allinfo.Count - 1)
i = 0;
this.richTextmain.AppendText(allinfo[i] + "\r");
this.richTextMemo.ScrollToEnd();
i++;
}

Frame 绑定

 string filepath = Environment.CurrentDirectory;
if (filepath.Substring(filepath.Length - 1) != "/")
filepath += "\\" + "MyHtml\\sdf.htm";
frame.Source = new Uri(filepath);

后台画路径/图形

void dTimer1_Tick(object sender, EventArgs e)
{
Random dr = new Random();
string varchar = chartData[dr.Next(0, chartData.Length)];
Thread.Sleep(1000);
if (varchar != null && varchar != "")
{
string[] v = varchar.Split(',');
Point p1 = new Point(Convert.ToInt32(v[0]), Convert.ToInt32(v[1]));
Point p2 = new Point(Convert.ToInt32(v[2]), Convert.ToInt32(v[3]));
Point p3 = new Point(Convert.ToInt32(v[4]), Convert.ToInt32(v[5]));
Point p4 = new Point(Convert.ToInt32(v[6]), Convert.ToInt32(v[7]));
Point[] values = new Point[] { p1, p2, p3, p4 };
StreamGeometry theGeometry = BuildRegularPolygon(values, true, true);
path1.Data = theGeometry;
}
}

WPF DataGrid

 <UserControl.Resources>
<!--DataGridRow-->
<Style TargetType="{x:Type DataGridRow}">
<Setter Property="IsTabStop"
Value="False" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridRow}">
<Grid Name="Root"> <Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
</Grid.ColumnDefinitions> <Rectangle x:Name="InvalidVisualElement"
Grid.RowSpan="2"
Grid.ColumnSpan="2"
Opacity="0.2"
Fill="#87CFFF" /> <DataGridCellsPresenter Grid.Column="1"
TextBlock.Foreground="Black"
Name="CellsPresenter" />
<Rectangle Grid.Row="2"
Grid.Column="1"
Fill="Transparent"
Name="BottomGridLine"
HorizontalAlignment="Stretch"
Height="1" />
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected"
Value="True">
<Setter Property="Fill"
TargetName="InvalidVisualElement"
Value="#FF9900" />
<Setter Property="Opacity"
Value="0.8"
TargetName="InvalidVisualElement" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type DataGridColumnHeader}">
<Setter Property="Foreground"
Value="White" />
<Setter Property="Background"
Value="#87CFFF" />
<Setter Property="IsTabStop"
Value="False" />
<Setter Property="SeparatorBrush"
Value="Black" />
<Setter Property="Height"
Value="Auto" />
<Setter Property="MinHeight"
Value="30" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridColumnHeader}">
<Grid Name="Root">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions> <Rectangle x:Name="BackgroundRectangle"
Stretch="Fill"
Fill="#87CFFF"
Opacity="0.5"
Grid.ColumnSpan="2" /> <Grid HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Margin="{TemplateBinding Padding}">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions> <ContentPresenter VerticalAlignment="Center"
HorizontalAlignment="Left"
Margin="6,0,0,0"
TextBlock.FontFamily="Segoe UI"
TextBlock.FontSize="14"
TextBlock.FontWeight="Regular"
Content="{TemplateBinding Content}" />
<!--<TextBlock VerticalAlignment="Center"
HorizontalAlignment="Left"
Margin="6,0,0,0"
TextBlock.FontFamily="Segoe UI"
TextBlock.FontSize="14"
TextBlock.FontWeight="Regular"
Text="{Binding RelativeSource={RelativeSource AncestorType=DataGridCell},Path=Content}" />--> <Path Grid.Column="1"
Name="SortIcon"
Fill="#87CFFF"
RenderTransformOrigin=".5,.5"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Opacity="0"
Stretch="Uniform"
Width="8"
Margin="4,0,0,0"
Data="F1 M -5.215,6.099L 5.215,6.099L 0,0L -5.215,6.099 Z ">
<Path.RenderTransform>
<ScaleTransform ScaleX=".9"
ScaleY=".9" />
</Path.RenderTransform>
</Path>
</Grid> <Rectangle Name="VerticalSeparator"
Grid.Column="1"
Width="1"
VerticalAlignment="Stretch"
Fill="{TemplateBinding SeparatorBrush}"
Visibility="{TemplateBinding SeparatorVisibility}" /> </Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!--DataGridCell-->
<Style TargetType="{x:Type DataGridCell}">
<Setter Property="Background"
Value="Transparent" />
<Setter Property="MinHeight"
Value="30" />
<Setter Property="Height"
Value="Auto" />
<Setter Property="IsTabStop"
Value="False" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridCell}">
<Grid Name="Root"
Background="{TemplateBinding Background}">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions> <ContentPresenter Content="{TemplateBinding Content}"
TextBlock.FontFamily="Segoe UI"
TextBlock.TextAlignment="Justify"
TextBlock.FontSize="14"
TextBlock.FontWeight="Regular"
ContentTemplate="{TemplateBinding ContentTemplate}"
VerticalAlignment="Center"
HorizontalAlignment="Left"
Margin="6,0,0,0" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style> <Style TargetType="{x:Type Hyperlink}">
<Setter Property="Foreground"
Value="Black" />
<Setter Property="Cursor"
Value="Hand" />
</Style> </UserControl.Resources>
<DataGrid
Margin="10,10,5,0"
Grid.Row="1"
Grid.Column="0"
Width="550"
Canvas.Right="1"
CanUserAddRows="False"
Name="grid1"
Foreground="Black"
VerticalScrollBarVisibility="Hidden"
HorizontalScrollBarVisibility="Hidden"
Background="Transparent" >
<DataGrid.Columns> <DataGridTemplateColumn Width="150">
<DataGridTemplateColumn.Header>
<TextBlock VerticalAlignment="Center" Foreground="White" Padding="5,5,5,5" TextWrapping="Wrap" TextTrimming="WordEllipsis" >kk</TextBlock>
</DataGridTemplateColumn.Header>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=kk}" VerticalAlignment="Center" Foreground="White" Padding="5,5,5,5" TextWrapping="Wrap" TextTrimming="WordEllipsis" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="120">
<DataGridTemplateColumn.Header>
<TextBlock VerticalAlignment="Center" Foreground="White" Padding="5,5,5,5" TextWrapping="Wrap" TextTrimming="uu" >Change Location</TextBlock>
</DataGridTemplateColumn.Header>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=uu}" VerticalAlignment="Center" Foreground="White" Padding="5,5,5,5" TextWrapping="Wrap" TextTrimming="WordEllipsis" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn Header="ss" Width="120" Foreground="White" Binding="{Binding ss}" />
<DataGridTextColumn Header="dd" Width="60" Foreground="White" Binding="{Binding dd}" />
</DataGrid.Columns>
</DataGrid> private void BindingTxt1()
{
ObservableCollection<ItemA21> Datalist = new ObservableCollection<ItemA21>();
string filename = "A21_new.txt";
int columns = 5;
int rows = 3;
try
{
string filepath = Environment.CurrentDirectory;
if (filepath.Substring(filepath.Length - 1) != "/")
filepath += "\\" + "DataFile\\" + filename;
StreamReader sr = new StreamReader(filepath, Encoding.Default);
string txtinfo = sr.ReadToEnd();
string[] strRows = txtinfo.Split(';');
int Total = strRows.Length;
Random ra = new Random();
int Filtered = 13;
for (int i = 0; i < Total; i++)
{
int j = ra.Next(1, Total);
ItemA21 item = new ItemA21();
string[] strColumns = strRows[i].Split(',');
if (strColumns.Length == columns)
{
string str0 = strColumns[0];
if (str0.IndexOf(":") > 0)
item.ss= str0.Substring(str0.IndexOf(":") + 1); string str1 = strColumns[1];
if (str1.IndexOf(":") > 0)
item.tt= str1.Substring(str1.IndexOf(":") + 1); string str2 = strColumns[2];
if (str2.IndexOf(":") > 0)
item.dd= str2.Substring(str2.IndexOf(":") + 1); string str3 = strColumns[3];
if (str3.IndexOf(":") > 0)
item.kk= str3.Substring(str3.IndexOf(":") + 1); string str4 = strColumns[4];
if (str4.IndexOf(":") > 0)
item.uu= str4.Substring(str4.IndexOf(":") + 1);
Datalist.Add(item);
}
else
{
//i--;
}
}
//for (int j = 0; j < rows - strRows.Length; j++)
//{
// ItemA21 item = new ItemA21();
// Datalist.Add(item);
//}
grid1.ItemsSource = Datalist;
sr.Close();
sr.Dispose();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message); }
}

WPF 中的相关样式的更多相关文章

  1. WPF 中的style 样式

    WPF相较于以前学的WinForm,WPF在UI设计与动画方面的炫丽是最吸引我来学习的.在WPF中XMAL代码的引入使得代码的编写能够前后端分离,为获得更好的界面,也使得我们不得不分出一半的时间花在前 ...

  2. WPF教程十:如何使用Style和Behavior在WPF中规范视觉样式

    在使用WPF编写客户端代码时,我们会在VM下解耦业务逻辑,而剩下与功能无关的内容比如动画.视觉效果,布局切换等等在数量和复杂性上都超过了业务代码.而如何更好的简化这些编码,WPF设计人员使用了Styl ...

  3. WPF中ListBox的样式设置

    设置之后的效果为

  4. WPF中样式和行为和触发器

    原文:WPF中样式和行为和触发器 样式简介:样式(style)是组织和重用格式化选项的重要工具,不是使用重复的标记填充XAML,以便设置外边距.内边距.颜色以及字体等细节.而是创建一系列封装所有这些细 ...

  5. WPF中的Style(风格,样式)(转)

    在WPF中我们可以使用Style来设置控件的某些属性值,并使该设置影响到指定范围内的所有该类控件或影响指定的某一控件,比如说我们想将窗口中的所有按钮都保持某一种风格,那么我们可以设置一个Style,而 ...

  6. C#、WPF中如何自定义鼠标样式

    需求:在C#中如何自定义鼠标样式?在这里可以分两种情况,一种是在winForm,另一种是在WPF中(注意使用的Cursor对象不一样) 解决办法如下: a.首先针对WinForm中,我们可以采用图标加 ...

  7. WPF中的Style(风格,样式)

    作者: 周银辉  来源: 博客园  发布时间: 2009-02-27 15:04  阅读: 6698 次  推荐: 0   原文链接   [收藏]   在WPF中我们可以使用Style来设置控件的某些 ...

  8. wpf中的样式与模板

    1.WPF样式类似于Web应用程序中的CSS,在WPF中可以为控件定义统一的样式(Style).样式属于资源的一种,例如为Button定义统一的背景颜色和字体: <Window.Resource ...

  9. WPF,SilverLight中直线的样式示例

    原文:WPF,SilverLight中直线的样式示例 XAML代码:// LineStyle.xaml<Viewbox Width="600" Height="50 ...

随机推荐

  1. LeetCode双周赛#36

    1604. 警告一小时内使用相同员工卡大于等于三次的人 题目链接 题意 给定两个字符串数组keyName和keyTime,分别表示名字为keytime[i]的人,在某一天内使用员工卡的时间(格式为24 ...

  2. MySQL必知必会:简介undo log、truncate、以及undo log如何帮你回滚事物

    目录 一.前言 二.undo log表空间 三.关于undo log默认的配置 四.如何将undo log放到单独的表空间 文章公众号首发,持续更新中 五.rollback segment 六.什么是 ...

  3. 区块链V1版本实现之一

    1. 程序地址:https://gitee.com/Jame_sz/beijing_go_term2.git 2. 程序编写流程: //1. 定义结构(区块头的字段比正常的少) //>1. 前区 ...

  4. Alpha冲刺-第八次冲刺笔记

    Alpha冲刺-冲刺笔记 这个作业属于哪个课程 https://edu.cnblogs.com/campus/fzzcxy/2018SE2 这个作业要求在哪里 https://edu.cnblogs. ...

  5. 深圳-2020-java面试题分享

    记录一下最近面试接触的面试题. 深圳掌众传媒: union 和union all区别 union:对两个结果集进行并集操作,不包括重复行,同时进行默认规则的排序: union All:对两个结果集进行 ...

  6. uwsgi+nginx的三种配置方式

    第一种 vi /etc/uwsgi.ini uwsgi --reload uwsgi.pid vi /etc/nginx/conf.d/iot.conf service nginx restart 第 ...

  7. go语言之---数组(array)和切片(slice)

    一.数组 1.什么是数组? 1.数组是一系列同一类型数据的集合 2.数组中包含的每个数据被称为数组元素 3.一个数组中包含的元素个数成为数组长度 4.数组的长度是固定的 5.一个数组可以由零个或者多个 ...

  8. aspnetcore webapi 解决发布以后每隔一段时间请求变缓慢

    项目:netcore webapi 3.1 平台:windows server 2008 r2 服务器:IIS 7.5 项目发布到IIS以后第一次请求特别慢大概7.8秒,然后每隔5分钟请求一次大概2. ...

  9. Angular:使用service进行http请求的简单封装

    ①使用ng g service services/storage创建一个服务组件 ②在app.module.ts 中引入HttpClientModule模块 ③在app.module.ts 中引入创建 ...

  10. Java 书单

    Java 基础 <Head First Java> 有人说这本书不适合编程新手阅读?其实本书还是很适合稍微有一点点经验的新手来阅读的,当然也适合我们用来温故 Java 知识点. ps:刚入 ...