如何覆盖默认依赖项属性元数据.例如; textbox的Text属性.我用这个代码
class UCTextBox : TextBox
{
public UCTextBox()
{
var defaultMetadata = TextBox.TextProperty.GetMetadata(typeof(TextBox));
TextBox.TextProperty.OverrideMetadata(typeof(UCTextBox),
new FrameworkPropertyMetadata(string.Empty,
FrameworkPropertyMetadataOptions.Journal |
FrameworkPropertyMetadataOptions.BindsTwoWayByDefault,
defaultMetadata.PropertyChangedCallback,
new CoerceValueCallback(CoerceText)
));
}
private static object CoerceText(DependencyObject d, object value)
{
return value.ToString().Replace(",","");
}
Run Code Online (Sandbox Code Playgroud)
但这在两次运行中(获取,设置)
没有人可以帮助我!!!:(((
我想Enum在EditorFor中展示.我使用编辑模板来显示它.(DropDownList).
我看到了麦芽EditorFor.我想为某些控件设置类.
@Html.EditorFor(m => m.Position, new { @class = "smallinput", style = "width:150px !important" })
@Html.EditorFor(m => m.DocumentType)
Run Code Online (Sandbox Code Playgroud)
在编辑器中:Views/Shared/DisplayTemplates/Enum.cshtml
@model Enum
@{
var values = Enum.GetValues(ViewData.ModelMetadata.ModelType).Cast<object>()
.Select(v => new SelectListItem
{
Selected = v.Equals(Model),
Text = v.GetDisplayName(),
Value = v.ToString()
});
}
@Html.DropDownList("", values)
Run Code Online (Sandbox Code Playgroud)
在模型中
[DisplayName("??? ???")]
[UIHint("Enum")]
public DocumentType DocumentType { get; set; }
Run Code Online (Sandbox Code Playgroud) 我有一个带图像的页面.我想把它设置在页面顶部.
<HTML>
<HEAD>
<title></title>
<style>
html, body {
margin: 0;
padding: 0;
}
</style>
</HEAD>
<BODY style="background-color:#3baa35;" >
<a href="" ><p align="center"><IMG border=0 src="home.PNG" ></p></a>
</BODY>
</HTML>
Run Code Online (Sandbox Code Playgroud)
但是页面顶部和正文之间有一行空格.
如何设置图像页面顶部?
我有一张这样的表。(VisitType 是动态的)
PersonelId VisitDate VisitTypeId
1 2015-02-24 A
2 2015-02-23 S
2 2015-02-24 D
4 2015-02-22 S
2 2015-02-22 A
2 2015-02-22 B
3 2015-02-23 A
1 2015-02-23 A
1 2015-02-24 D
4 2015-02-24 S
4 2015-02-22 S
2 2015-02-22 S
3 2015-02-24 D
Run Code Online (Sandbox Code Playgroud)
我想使用 linq 获得一个支点,如下所示。
VisitDate PersonelId A S D B
2015-02-22 4 0 2 0 0
2015-02-22 2 1 1 0 0
2015-02-23 2 0 1 0 0
2015-02-23 3 1 0 0 0
2015-02-23 1 1 …Run Code Online (Sandbox Code Playgroud) 我创建了一个结构
public struct MyCalender : IComparable<MyCalender>
{
public int CompareTo(PersianDate other)
{
return DateTime.Compare(this, other);
}
.
.
.
.
.
}
Run Code Online (Sandbox Code Playgroud)
我在另一个UserControl中新增了两个这个对象,我想要比较它们.
我使用此代码,但我得到错误.
MyCalender value = new MyCalender(2010,11,12);
MyCalender value2 = new MyCalender(2010,11,12);
if (value < value2) ==> geterror
Run Code Online (Sandbox Code Playgroud) 我在核心中使用身份。
在启动时。
services.AddSingleton<ICurrentUserService, CurrentUserService>();
services.AddHttpContextAccessor();
Run Code Online (Sandbox Code Playgroud)
并在帐户控制器中
[ApiController]
[Route("api/[controller]")]
public class AccountController : Controller
{
private readonly IApplicationUserManager _userManager;
private readonly SignInManager<ApplicationUser> _signInManager;
public AccountController
(IApplicationUserManager userManager,
SignInManager<ApplicationUser> signInManager)
{
_userManager = userManager;
//_roleManager = roleManager;
_signInManager = signInManager;
}
[HttpPost("Login")]
[AllowAnonymous]
public async Task<IActionResult> Login(LoginViewModel model)
{
try
{
await _signInManager.SignOutAsync();
var result = await _signInManager.PasswordSignInAsync(model.email, model.password, true, false);
if (result.Succeeded)
{
return Json(new { success = true});
}
var message = string.Join("; ", ModelState.Values
.SelectMany(x => x.Errors)
.Select(x => …Run Code Online (Sandbox Code Playgroud) 我在View中捍卫了Storyborad
<Storyboard x:Key="ExpandAdd" >
<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="AddUsers" Storyboard.TargetProperty="(UIElement.Visibility)">
<DiscreteObjectKeyFrame KeyTime="00:00:00" Value="{x:Static Visibility.Collapsed}"/>
<DiscreteObjectKeyFrame KeyTime="00:00:00.3000000" Value="{x:Static Visibility.Visible}"/>
</ObjectAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="DetailBorder" Storyboard.TargetProperty="(UIElement.Opacity)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
<SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="0.4"/>
</DoubleAnimationUsingKeyFrames>
<BooleanAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="DetailBorder" Storyboard.TargetProperty="(UIElement.IsEnabled)">
<DiscreteBooleanKeyFrame KeyTime="00:00:00" Value="False"/>
</BooleanAnimationUsingKeyFrames>
</Storyboard>
Run Code Online (Sandbox Code Playgroud)
我有一个按钮并绑定到relaycommand。
<Button x:Name="AddUserButton" Content="?????">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<cmd:EventToCommand Command="{Binding AddUsers}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
Run Code Online (Sandbox Code Playgroud)
我想在执行RelayCommand(AddUsers)时播放情节提要。
c# ×3
css ×2
wpf ×2
.net-core ×1
asp.net-core ×1
asp.net-mvc ×1
group-by ×1
html ×1
linq ×1
mvvm ×1
pivot ×1
pivot-table ×1