为了描述我的问题,我创建了一个小应用程序。首先,用户控件:
<UserControl x:Class="WpfApplication10.UserControl1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Name="This" DataContext="{Binding ElementName=This}"
>
<Image Source="{Binding Path=MyImageSource}" ></Image>
</UserControl>
Run Code Online (Sandbox Code Playgroud)
第二个TestApp:
<Window x:Class="WpfApplication10.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:WpfApplication10="clr-namespace:WpfApplication10"
Title="Window1" Height="300" Width="300">
<WpfApplication10:UserControl1
MyImageSource="c:\test.png" >
</WpfApplication10:UserControl1>
</Window>
Run Code Online (Sandbox Code Playgroud)
第三条用户控件背后的代码
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Imaging;
namespace WpfApplication10
{
public partial class UserControl1 : UserControl
{
public static readonly DependencyProperty MyImageSourceProperty =
DependencyProperty.Register("MyImageSource",
typeof(BitmapImage),typeof(UserControl1),
new FrameworkPropertyMetadata((BitmapImage)new BitmapImage(),
FrameworkPropertyMetadataOptions.None
));
public BitmapImage MyImageSource
{
get { return (BitmapImage)GetValue(MyImageSourceProperty); }
set { SetValue(MyImageSourceProperty, value); }
}
public UserControl1()
{
InitializeComponent();
}
}
} …
Run Code Online (Sandbox Code Playgroud) 我觉得我缺乏一些真正的基础知识,如果在这里提出所有这些基本问题,我觉得我会浪费你的时间.能否请您推荐一本很好的PowerPoint VBA教程,向我解释基础知识.提供了一个带有例子的教程.
在友好的URL中显示日期范围的公认惯例是什么?
例如,在时间跟踪应用程序中.我想使用更容易区分用户的东西,而不是使用数据库的主键来处理URL中的特定付费期.
http://www.mytimesheet.com/11-1-2009-11-14-2009
http://www.mytimesheet.com/period-beginning-11-1-2009
Run Code Online (Sandbox Code Playgroud)
这些似乎都没有削减它,但也许我只是过于批评.
我希望使用Grid作为我的顶级布局.网格将有1列和n行.Grid中的每一行还应包含一个Grid,该Grid应包含3列和1行.在第二列是GridSplitter,我试图使用SharedSizeGroup,这样就可以改变所有嵌套网格中第一列的大小.
这就是我所拥有的...它的工作原理!! ......很好......如果你点击分离器并调整大小而不放手它可以工作......但出于某种原因,如果你调整大小并放开鼠标,然后尝试使用不同的行调整大小,似乎"坚持".
有任何想法吗?
<!-- Parent Grid -->
<Grid Grid.IsSharedSizeScope="True">
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<!-- First Grid -->
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition SharedSizeGroup="A" Width="Auto"></ColumnDefinition>
<ColumnDefinition SharedSizeGroup="B" Width="Auto"></ColumnDefinition>
<ColumnDefinition SharedSizeGroup="C" Width="Auto"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Label Grid.Column="0">One-Left</Label>
<GridSplitter Grid.Column="1" Width="5" Background="DarkGray"></GridSplitter>
<Label Grid.Column="2">One-Right</Label>
</Grid>
<!-- Second Grid -->
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition SharedSizeGroup="A" Width="Auto"></ColumnDefinition>
<ColumnDefinition SharedSizeGroup="B" Width="Auto"></ColumnDefinition>
<ColumnDefinition SharedSizeGroup="C" Width="Auto"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Label Grid.Column="0">Two-Left</Label>
<GridSplitter Grid.Column="1" Width="5" Background="DarkGray"></GridSplitter>
<Label Grid.Column="2">Two-Right</Label>
</Grid>
</Grid>
Run Code Online (Sandbox Code Playgroud) 确保只有给定脚本的一个实例运行的最简单/最好的方法是什么 - 假设它是Linux上的Bash?
目前我正在做:
ps -C script.name.sh > /dev/null 2>&1 || ./script.name.sh
Run Code Online (Sandbox Code Playgroud)
但它有几个问题:
-C
仅检查进程名称的前14个字符当然,我可以编写自己的pidfile处理,但我觉得应该有一个简单的方法来实现它.
我一直在网页上测试带有嵌入式Flash组件的PS3浏览器(NetFront),并且发出任何来自Flash的请求的方式似乎都存在相当严重的错误.浏览器正在添加引用者(referer),因此Flash播放器也会导致重复的标题.如果引用者标题相同,这实际上是正常的,但它们不是,因此请求由W2k8上的http.sys停止.这对我来说是一个主要问题,因为我有一个需要调用Web服务才能运行的Flash组件.
我们是否有某种方式可以过滤或允许这些请求,可能会沿途重复删除标题.
我们已经考虑过但我们的开发和实时环境不是最理想或不可能的一些解决方案是:
作为参考,以下请求将重现问题(复制并粘贴到Fiddler或其他工具中,我假设您正在运行IIS7,W2K8,因为我们是).你应该得到400 Bad Request
回应.
GET / HTTP/1.1 Host: localhost Referer: http://localhost/NetFrontBrowser/ Referer: http://localhost/Flash/
非常感谢
我有一些来自其他层的数据,它代表一个EF对象.当它是新的时,我这样做:
context.AddToCustomer(mynewobject);
context.SaveChanges();
Run Code Online (Sandbox Code Playgroud)
但现在我的数据形成了一个现有的对象,所以我希望上下文知道我想要更新数据而不是插入数据.
我见过'ApplyPropertyChanges',但我无法弄清楚如何使用它.我也见过人们这样做:
Customer existingOne = (from n in context.Customers
where n.id = mynewobject.id select n).First()
existingOne.name = mynewobject.name
existingOne.address= mynewobject.address
context.SaveChanges();
Run Code Online (Sandbox Code Playgroud)
但这似乎有点奇怪,因为我必须手动设置所有道具并首先读取整个对象.
有谁知道好的/免费的CDN?我们正在托管一个小型Web应用程序,并希望从CDN加载Jquery JavaScripts.建议将不胜感激.
我需要删除3个向量或更多向量之间没有相同值的所有元素.例如,
vector<int> Vector1, Vector2, Vector3;
for(int i = 2; i < 7; i++) Vector1.push_back(i); // Vector1 = {2, 3, 4, (5), (6)}
for(int i = 3; i < 8; i++) Vector2.push_back(i); // Vector2 = {3, 4, (5), (6), 7}
for(int i = 5; i < 10; i++) Vector3.push_back(i); // Vector3 = {(5), (6), 7, 8, 9}
Run Code Online (Sandbox Code Playgroud)
我们知道所有向量都有2个具有相同值的元素:5和6.现在我如何获取这些值并将它们存储到新的向量中?
任何形式的帮助将不胜感激:)
我有两个类A和B.许多B可以与单个A关联,因此从B到A的多对一关系.我已经映射了这样的关系:
<class name="A" table="tbl_A">
<property name="propA" column="colA"/>
</class>
<class name="B" table="tbl_B">
<property name="propB" column="colB"/>
<many-to-one name="a" class="A" column="col1" cascade="delete"/>
</class>
Run Code Online (Sandbox Code Playgroud)
A没有任何映射到B.记住这一点,我们打算在删除关联A时删除B. 如果我可以在B中的多对一关联上定义inverse ="true",那么这可能是可能的,但是hibernate不允许这样做.
有人能帮忙吗?我们不想为此写任何东西.