Setting Margin Properties in code
http://stackoverflow.com/questions/1003772/setting-margin-properties-in-code
The problem is that Margin
is a property, and its type (Thickness
) is a value type. That means when you access the property you're getting a copy of the value back.
Even though you can change the value of the Thickness.Left
property for a particular value (grr... mutable value types shouldn't exist), it wouldn't change the margin.
Instead, you'll need to set the Margin
property to a new value. For instance (coincidentally the same code as Marc wrote):
Thickness margin = MyControl.Margin;
margin.Left = 10;
MyControl.Margin = margin;
As a note for library design, I would have vastly preferred it if Thickness
were immutable, but with methods that returned a new value which was a copy of the original, but with one part replaced. Then you could write:
MyControl.Margin = MyControl.Margin.WithLeft(10);
No worrying about odd behaviour of mutable value types, nice and readable, all one expression...
Setting Margin Properties in code的更多相关文章
- Set Java Proxy for Http/Https
Command Line JVM Settings The proxy settings are given to the JVM via command line arguments: java ...
- spring mvc DispatcherServlet详解之三---request通过ModelAndView中获取View实例的过程
整个spring mvc的架构如下图所示: 上篇文件讲解了DispatcherServlet第二步:通过request从Controller获取ModelAndView.现在来讲解第三步:reques ...
- linux命令行模式下实现代理上网(转)
有些公司的局域网环境,例如我们公司的只允许使用代理上网,图形界面的很好解决就设置一下浏览器的代理就好了,但是linux纯命令行的界面就....下面简单几步就可以实现了! 一.命令行界面的一般代理设置方 ...
- linux命令行模式下实现代理上网 专题
有些公司的局域网环境,例如我们公司的只允许使用代理上网,图形界面的很好解决就设置一下浏览器的代理就好了,但是linux纯命令行的界面就....下面简单几步就可以实现了! 一.命令行界面的一般代理设置方 ...
- Spring中配置和读取多个Properties文件--转
public class PropertiesFactoryBeanextends PropertiesLoaderSupportimplements FactoryBean, Initializin ...
- Margin and Padding in Windows Forms Controls
https://msdn.microsoft.com/en-us/library/ms229627.aspx Margin and Padding Precise placement of contr ...
- Visual Studio - File Properties (Build Action, Copy to Output Directory)
Ref: MSDN (https://docs.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2010/0c6xyb ...
- util:properties
示例 <util:properties id="db" location="classpath:db.properties" /> 全部属性 功能概 ...
- [转]Entity Framework Fluent API - Configuring and Mapping Properties and Types
本文转自:https://msdn.microsoft.com/en-us/data/jj591617#1.2 When working with Entity Framework Code Firs ...
随机推荐
- 关于CentOS 7.1后期维护的问题
1.问题描述:在使用ssh服务远程登录的时候,当显示输入密码,特别特别的慢,刚刚搭建 服务器的时候还很正常,经过一个假期我实在忍不了它了,故决定解决此问题.服务器系统:CentOS 7.1 解决方式: ...
- 删除项目中的.svn文件
删除项目中的.svn文件 1.创建个文件,名字改为kill-svn-folders.reg 2.把下面的代码考进去,每一行前面不要留空, Windows Registry Editor Version ...
- C语言中关键字volatile的含义【转】
本文转载自:http://m.jb51.net/article/37489.htm 本篇文章是对C语言中关键字volatile的含义进行了详细的分析介绍,需要的朋友参考下 volatile 的意思是“ ...
- python paramiko ssh.exec_command()启动tomcat服务器应用进程失败问题解决方法- Neither the JAVA_HOME nor the JRE_HOME environment variable is defined At least one of these environment variable is needed to run this progr
问题说明:
- WordPress博客系统搜索引擎优化seo全攻略方法
WordPress的文章.评论等很多数据都是存放在数据库的,所以搭建wordpress网站的时间,网站的空间不需要多大,而数据库一定要充足,而在WordPress数据库中主要使用 wp_posts 表 ...
- Lucas定理模板
用于大组合数对p取模的计算. #include <cstdio> #include <iostream> #include <cmath> #include < ...
- C#:WPF绘制问题
1.问题描述:切换画笔后,鼠标呈现画笔,但绘制界面需要点击后才能绘制,体验比较差 注:如果将切换为画笔或橡皮擦的功能放在二级菜单中则无次问题 解决方法(大体如此): 1)在第三方中,先创建完绘制画面和 ...
- mysql传统主从、双主复制+keepalived配置步骤
mysql主从.主主复制(双主复制)配置步骤 一:MySQL复制: MySQL复制简介: 将master服务器中主数据库的ddl和dml操作通过二进制日志传到slaves服务器上,然后在master服 ...
- java 面试每日一题2
题目:输入一行字符,分别统计出其中英文字母.空格.数字和其它字符的个数. 注:如果想单独输出中文的个数和中文符号的个数,只需把isChinese()中的if语句修改 知识补充: java不像C中拥有s ...
- css常用命名规则
(一)常用的CSS命名规则 头:header 内容:content/container 尾:footer 导航:nav 侧栏:sidebar 栏目:column 页面外围控制整体布局宽度:wrappe ...