我正在尝试将Solver Foundation添加到我正在Visual Studio 2012中工作的项目中,但我无法在列表中找到它.
我打开了一个示例项目,引用的是Microsoft.Solver.Foundation但是我尝试在我的项目中的所有可用列表上搜索Microsoft.S并且它没有出现.
如何将Solver Foundation纳入我的项目?
我正在尝试设置一个TextBox子类,它将根据一些不同的东西改变它的样式,我遇到了两个问题.第一个触发器,即VisualBrush触发器,可以正确触发,但不会在String myName中写入文本.我尝试将myName设为属性但由于某种原因set方法抛出StackOverFlowException.
第二个问题是DataTrigger,即使isRequired设置为false,也不会被触发.
这都在继承TextBox的自定义控件中.
这是我的XAML:
<TextBox.Style>
<Style TargetType="TextBox">
<Style.Triggers>
<Trigger Property="Text" Value="">
<Setter Property="Background">
<Setter.Value>
<VisualBrush Stretch="None">
<VisualBrush.Visual>
<TextBlock Foreground="Gray" FontSize="24">
<TextBlock.Text>
<Binding Path="myName" RelativeSource="{RelativeSource Self}" />
</TextBlock.Text>
</TextBlock>
</VisualBrush.Visual>
</VisualBrush>
</Setter.Value>
</Setter>
</Trigger>
<DataTrigger Binding="{Binding Path=isRequired, Source={RelativeSource Self}}" Value="False">
<Setter Property="Text" Value="100" />
</DataTrigger>
</Style.Triggers>
</Style>
</TextBox.Style>
Run Code Online (Sandbox Code Playgroud)
CS:
public partial class SuperTB : TextBox
{
public String myName
{
get { return myName; }
set {}
}
DependencyProperty isRequiredProperty = DependencyProperty.Register("isRequired", typeof(Boolean), typeof(SuperTB));
public Boolean isRequired
{
get { …Run Code Online (Sandbox Code Playgroud)