我有一个小型的Web应用程序.哪个工作正常,直到我在我的应用程序中添加了两个genericHandler.
我对http处理程序进行了以下更改
<system.web>
<authentication mode="Forms" >
<forms protection="All" timeout="720" defaultUrl="Default.aspx" loginUrl="Login.aspx" >
</forms>
</authentication>
<authorization>
<deny users="?"/>
</authorization>
<compilation debug="true" targetFramework="4.0" />
<httpHandlers>
<!--Code Log Handler-->
<add verb="*" path="*.aspx" type="System.Web.UI.PageHandlerFactory" />
<add verb="*" type="InfoDomeNewUI.Handler.SendOWA" path="SendOWA.ashx" />
<add verb="*" type="InfoDomeNewUI.Handler.SendSOS" path="SendSOS.ashx" />
</httpHandlers>
<customErrors mode="Off">
<error statusCode="404" redirect="Templates/PageNotFound.html" />
</customErrors>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<!--Code Log Handler-->
<add name="LogHandler1" path="SendOWA.ashx" verb="*" type="InfoDomeNewUI.Handler.SendOWA"/>
<!-- SMS SENDER-->
<add name="SendSOS" path="SendSOS.ashx" verb="*" type="InfoDomeNewUI.Handler.SendSOS"/>
</handlers>
</system.webServer>
Could not load file or assembly 'Microsoft.Web.Infrastructure, …
Run Code Online (Sandbox Code Playgroud) 我有以下示例代码,每次按下按钮时缩放:
XAML:
<Window x:Class="WpfApplication12.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Canvas x:Name="myCanvas">
<Canvas.LayoutTransform>
<ScaleTransform x:Name="myScaleTransform" />
</Canvas.LayoutTransform>
<Button Content="Button"
Name="myButton"
Canvas.Left="50"
Canvas.Top="50"
Click="myButton_Click" />
</Canvas>
</Window>
Run Code Online (Sandbox Code Playgroud)
*的.cs
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void myButton_Click(object sender, RoutedEventArgs e)
{
Console.WriteLine("scale {0}, location: {1}",
myScaleTransform.ScaleX,
myCanvas.PointToScreen(GetMyByttonLocation()));
myScaleTransform.ScaleX =
myScaleTransform.ScaleY =
myScaleTransform.ScaleX + 1;
Console.WriteLine("scale {0}, location: {1}",
myScaleTransform.ScaleX,
myCanvas.PointToScreen(GetMyByttonLocation()));
}
private Point GetMyByttonLocation()
{
return new Point(
Canvas.GetLeft(myButton),
Canvas.GetTop(myButton));
}
}
Run Code Online (Sandbox Code Playgroud)
输出是:
scale 1, location: …
Run Code Online (Sandbox Code Playgroud) 默认情况下,Validation.ErrorTemplate
在WPF只是一个小红色边框没有任何ToolTip
.
在Silverlight 4中,验证错误很好地开箱即用.
以下是Silverlight 4和WPF中出现的验证错误的比较
Silverlight 4
WPF
请注意WPF版本的平坦,无聊的外观与我认为的Silverlight外观相比.
WPF框架中是否存在任何类似的验证样式/模板,或者是否有人创建了很好的样式验证模板,如上面的Silverlight版本?或者我是否必须从头开始创建它们?
如果有人想尝试一下,可以使用以下代码重现上面的验证错误,适用于Silverlight和WPF
主窗口/ MainPage.xaml中
<StackPanel Orientation="Horizontal" Margin="10" VerticalAlignment="Top">
<TextBox Text="{Binding Path=TextProperty, Mode=TwoWay, ValidatesOnExceptions=True}"/>
<Button Content="Tab To Me..." Margin="20,0,0,0"/>
</StackPanel>
Run Code Online (Sandbox Code Playgroud)
主窗口/ MainPage.xaml.cs中
public MainWindow/MainPage()
{
InitializeComponent();
this.DataContext = this;
}
private string _textProperty;
public string TextProperty
{
get { return _textProperty; }
set
{
if (value.Length > 5)
{
throw new Exception("Too many characters");
}
_textProperty = value;
} …
Run Code Online (Sandbox Code Playgroud) WPF TreeView中的所选项目具有深蓝色背景和"尖锐"角.今天看起来有点过时了:
我想改变背景,看起来像在Windows 7的资源管理器中(有/无焦点):
我到目前为止所尝试的并没有删除原始的深蓝色背景,而是在它上面画了一个圆形边框,这样你就可以看到边缘和左边的深蓝色 - 丑陋.
有趣的是,当我的版本没有焦点时,它看起来很不错:
我想不要重新定义控件模板,如此处或此处所示.我想设置所需的最小属性,使所选项目在资源管理器中看起来像.
替代方案:我也很乐意将焦点选中的项目看起来像我现在所做的那样没有焦点.失去焦点时,颜色应从蓝色变为灰色.
这是我的代码:
<TreeView
x:Name="TreeView"
ItemsSource="{Binding TopLevelNodes}"
VirtualizingStackPanel.IsVirtualizing="True"
VirtualizingStackPanel.VirtualizationMode="Recycling">
<TreeView.ItemContainerStyle>
<Style TargetType="{x:Type TreeViewItem}">
<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" />
<Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="BorderBrush" Value="#FF7DA2CE" />
<Setter Property="Background" Value="#FFCCE2FC" />
</Trigger>
</Style.Triggers>
</Style>
</TreeView.ItemContainerStyle>
<TreeView.Resources>
<HierarchicalDataTemplate DataType="{x:Type viewmodels:ObjectBaseViewModel}" ItemsSource="{Binding Children}">
<Border Name="ItemBorder" CornerRadius="2" Background="{Binding Background, RelativeSource={RelativeSource AncestorType=TreeViewItem}}"
BorderBrush="{Binding BorderBrush, RelativeSource={RelativeSource AncestorType=TreeViewItem}}" BorderThickness="1">
<StackPanel Orientation="Horizontal" Margin="2">
<Image Name="icon" Source="/ExplorerTreeView/Images/folder.png"/>
<TextBlock Text="{Binding Name}"/> …
Run Code Online (Sandbox Code Playgroud) 如何设置wpf数据网格的网格线的颜色?我可以用属性隐藏这些行GridLinesVisibility
,但我不知道如何为它们着色.我尝试使用行和单元格的Borderbrush,但我没有成功.
OneWayToSource
在.NET 4.0中,绑定似乎已经破裂
我有这个简单的Xaml
<StackPanel>
<TextBox Text="{Binding TextProperty, Mode=OneWayToSource}"/>
<Button/>
</StackPanel>
Run Code Online (Sandbox Code Playgroud)
我的代码背后看起来像这样
public MainWindow()
{
InitializeComponent();
this.DataContext = this;
}
private string m_textProperty;
public string TextProperty
{
get
{
return "Should not be used in OneWayToSource Binding";
}
set
{
m_textProperty = value;
}
}
Run Code Online (Sandbox Code Playgroud)
在.NET 3.5中,这可以像你一样工作.将一些文本放入TextBox
,按Tab键使其失去焦点,并TextProperty
使用输入的任何文本进行更新TextBox
在.NET 4.0中,如果我在其中键入一些文本TextBox
然后按Tab键使其失去焦点,则TextBox
恢复为TextProperty
(意味着"不应在OneWayToSource绑定中使用")的值.这是重读用于OneWayToSource
.NET 4.0中的绑定吗?我只是想把TextBox
它的价值推向TextProperty
而不是相反.
更新
为此问题添加赏金,因为这已成为我项目中的市长不便,我想知道这已经改变的原因.似乎get
在Binding更新源之后调用.这是OneWayToSource
.NET 4.0中绑定所需的行为吗?
如是
我需要删除组合框周围的红色矩形.我在xaml中设置了combobox,如下所示,我试图覆盖Validation.ErrorTemplate.
<ComboBox x:Name="comboPodkategoria"
Margin="0,3,0,0"
IsSynchronizedWithCurrentItem="False"
IsEditable="False"
ItemsSource="{Binding Source={StaticResource PodKategoriaLookup}, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}"
SelectedValue="{Binding IDPodKategoria}"
DisplayMemberPath="kat_popis" SelectedValuePath="IDPodkat" TabIndex="5" Style="{StaticResource combostyle}">
<Validation.ErrorTemplate>
<ControlTemplate>
</ControlTemplate>
</Validation.ErrorTemplate>
</ComboBox>
Run Code Online (Sandbox Code Playgroud)
用于删除红色矩形的样式,但在xaml中有一些错误,表示Visibility属性无法识别或无法访问.样式定义如下.
<Style x:Key="combostyle">
<Style.Triggers>
<Trigger Property="Validation.HasError" Value="True">
<Setter Property="Visibility" TargetName="NotValid" Value="Visible"/>
</Trigger>
</Style.Triggers>
Run Code Online (Sandbox Code Playgroud)
任何的想法?:(
我目前正在尝试实现Metro风格的窗口.
所以我在ResourceDictionary中创建了以下样式:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<!-- Brushes -->
<SolidColorBrush x:Key="BackgroundColor" Color="#FFFFFFFF" />
<!-- Buttons -->
<Style x:Key="MetroControlBoxButton" TargetType="Button">
<Setter Property="Background" Value="{StaticResource BackgroundColor}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<ContentPresenter />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- Windows -->
<Style x:Key="MetroWindow" TargetType="Window">
<Setter Property="UseLayoutRounding" Value="True" />
<Setter Property="WindowStyle" Value="None" />
<Setter Property="ResizeMode" Value="NoResize" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Window">
<Grid Background="{StaticResource BackgroundColor}">
<Grid.RowDefinitions>
<RowDefinition Height="6" />
<RowDefinition Height="24" />
<RowDefinition Height="*" />
<RowDefinition Height="24" />
<RowDefinition Height="6" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="6" …
Run Code Online (Sandbox Code Playgroud) 我有一节课:
public class AccountDetail
{
public DetailScope Scope
{
get { return scope; }
set { scope = value; }
}
public string Value
{
get { return this.value; }
set { this.value = value; }
}
private DetailScope scope;
private string value;
public AccountDetail(DetailScope scope, string value)
{
this.scope = scope;
this.value = value;
}
}
Run Code Online (Sandbox Code Playgroud)
和一个枚举:
public enum DetailScope
{
Private,
Business,
OtherDetail
}
Run Code Online (Sandbox Code Playgroud)
最后,我有一个.xaml文件:
<Window x:Class="Gui.Wpf.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Test"
SizeToContent="WidthAndHeight">
<Grid>
<ComboBox
Name="ScopeComboBox"
Width="120"
Height="23"
Margin="12" /> …
Run Code Online (Sandbox Code Playgroud) 我有一个像这样定义的简单TextBlock
<StackPanel>
<Border Width="106"
Height="25"
Margin="6"
BorderBrush="Black"
BorderThickness="1"
HorizontalAlignment="Left">
<TextBlock Name="myTextBlock"
TextTrimming="CharacterEllipsis"
Text="TextBlock: Displayed text"/>
</Border>
</StackPanel>
Run Code Online (Sandbox Code Playgroud)
哪个输出像这样
这会让我"TextBlock:显示文字"
string text = myTextBlock.Text;
Run Code Online (Sandbox Code Playgroud)
但有没有办法获得实际显示在屏幕上的文字?
含义"TextBlock:显示......"
谢谢
wpf ×9
xaml ×7
c# ×4
.net ×2
combobox ×2
styles ×2
asp.net ×1
binding ×1
command ×1
data-binding ×1
datagrid ×1
events ×1
selecteditem ×1
silverlight ×1
styling ×1
text ×1
textblock ×1
texttrimming ×1
treeview ×1
validation ×1