嗨,我对Html.ActionLink有疑问.
想像:
@Html.ActionLink(item.title, "Singlet", new { id = item.blog_id })
Run Code Online (Sandbox Code Playgroud)
产生http:// [url]/[controller]/Singlet/[id]
但是,如果我想在最后添加一些更随意的数据呢?例如:
HTTP:// [URL]/[控制器] /背心/ [ID] /#评论
跳转到评论div.我知道我可以用以下内容自己制作字符串:
@( new HtmlString(String.Format("<a href=\"Blog/Singlet/{0}/#comments\">link to comments</a>", item.blog_id)) )
Run Code Online (Sandbox Code Playgroud)
但我希望有一种更清洁的方式,也许是使用ActionLink?
谢谢
问:如何从子控件的样式DataTrigger绑定到模板父的自定义属性
我已经在这个问题上摸不着头几天了.
我有一个数据绑定TreeView,它使用一个具有模板的Style.TreeView绑定到ObservableCollection,HierarchicalDataTemplate + DataTemplate绑定到集合项内的属性.
FontGroup - >字体
<Style x:Key="ExpandCollapseToggleStyle" TargetType="{x:Type ToggleButton}">
...
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Image x:Name="ExpanderImage" Source="/Typesee;component/Resources/tree_expand.png" RenderOptions.BitmapScalingMode="NearestNeighbor" />
<ControlTemplate.Triggers>
<DataTrigger Binding="??? IsItemSelected ???" Value="True">
<Setter TargetName="ExpanderImage" Property="Source" Value="/Typesee;component/Resources/tree_collapse_selected.png" />
</DataTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<ControlTemplate x:Key="FontTreeViewTemplate" TargetType="{x:Type TreeViewItem}">
...
<ToggleButton x:Name="Expander" Style="{StaticResource ExpandCollapseToggleStyle}" ... />
...
<ControlTemplate.Triggers>
<DataTrigger Binding="{Binding IsItemSelected}" Value="True">
<!-- WORKS FINE HERE -->
</DataTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
Run Code Online (Sandbox Code Playgroud)
首先我尝试绑定:
Binding Path=IsItemSelected, RelativeSource={RelativeSource TemplatedParent}
Run Code Online (Sandbox Code Playgroud)
然后我读到这可能不起作用所以我尝试了(包括AncestorLevel 1 + 3):
Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type TreeViewItem}, …Run Code Online (Sandbox Code Playgroud) 我来自AMD,似乎已经做错了.
我做了这样的设置:
client/js/index.js (entry point)
client/js/test.js
Run Code Online (Sandbox Code Playgroud)
我希望它建立:
build/app.js
Run Code Online (Sandbox Code Playgroud)
index.js需要test.js像这样:
var test = require('./test');
Run Code Online (Sandbox Code Playgroud)
我的gulp watchify任务看起来像这样:
var gulp = require('gulp');
var gutil = require('gulp-util');
var browserify = require('browserify');
var source = require('vinyl-source-stream');
var watchify = require('watchify');
// https://github.com/gulpjs/gulp/blob/master/docs/recipes/fast-browserify-builds-with-watchify.md
gulp.task('watch', function () {
var bundler = watchify(browserify('./client/js/index.js', watchify.args));
bundler.on('update', rebundle);
function rebundle () {
return bundler.bundle()
// Log errors if they happen.
.on('error', function(e) {
gutil.log('Browserify Error', e.message);
})
.pipe(source('app.js'))
.pipe(gulp.dest('./build'));
}
return rebundle();
});
Run Code Online (Sandbox Code Playgroud)
编译后的代码看起来很糟糕,因为test.js …
我想根据祖先不存在的另一个类来设置一个类的样式。
div:not(.evil-class) .element {
background-color: green;
}Run Code Online (Sandbox Code Playgroud)
<div class="evil-class">
<div class="element">An element within the evil class</div>
</div>
<div class="element">An element NOT in the evil class</div>Run Code Online (Sandbox Code Playgroud)
不确定为什么不起作用?
我知道我可以做相反的事情。对两个元素都应用样式,然后覆盖该样式,但是我不愿意这样做,因为我将覆盖可能在第三方库中更改的样式。
谢谢。
actionlink ×1
asp.net ×1
binding ×1
browserify ×1
css ×1
findancestor ×1
gulp ×1
html ×1
javascript ×1
parent ×1
system-paths ×1
templates ×1
watchify ×1
wpf ×1