我试图绑定一个依赖于同一控件的属性DataTemplate.
为了显示:
<DataTemplate>
<StackPanel Orientation="Horizontal">
<ComboBox x:Name="ComboList"
ItemsSource="{Binding StatTypes}"
SelectedItem="{Binding SelectedStatType, Mode=TwoWay, FallbackValue='Select a type'}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Text}"/>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<TextBox Grid.Column="1" MinWidth="40" Margin="5">
<TextBox.Text>
<Binding Path="StatValue">
<Binding.Converter>
<converter:PercentageConverter SelectedStatType="{Binding ElementName=ComboList, Path=SelectedItem}" />
</Binding.Converter>
</Binding>
</TextBox.Text>
</TextBox>
</StackPanel>
</DataTemplate>
Run Code Online (Sandbox Code Playgroud)
但是这里的财产PercentageConverter从来没有通过这个,我不明白为什么.这是一个命名范围问题吗?如果是这样的话,我认为这不重要,因为它是相同的DataTemplate
如果不是,我做错了什么?
我正在使用Microsoft Interactivity和Microsoft Interactions在我的代码隐藏中基于Property旋转对象.为了使旋转更加平滑,我添加了一个缓动功能.它可以完美地制作动画,但是当它到达动画结束的1个分割帧时,旋转将重置为动画之前的值,然后切换回旋转后的值,导致它来回"抽搐" .这只发生在EaseOut上.
<i:Interaction.Triggers>
<ie:PropertyChangedTrigger Binding="{Binding Rotation}">
<ie:ChangePropertyAction TargetName="RotateTransformer" PropertyName="Angle" Value="{Binding Rotation}" Duration="0:0:2">
<ie:ChangePropertyAction.Ease>
<BackEase EasingMode="EaseOut" Amplitude="1.2" />
</ie:ChangePropertyAction.Ease>
</ie:ChangePropertyAction>
</ie:PropertyChangedTrigger>
</i:Interaction.Triggers>
<Path Stroke="Black" Fill="Gray">
<Path.RenderTransform>
<RotateTransform x:Name="RotateTransformer" CenterX="64" CenterY="105" />
</Path.RenderTransform>
<Path.Data>
<PathGeometry>
<PathFigureCollection>
<PathFigure StartPoint="64,0" >
<LineSegment Point="39,110" />
<LineSegment Point="64, 70" />
<LineSegment Point="39,180" />
<LineSegment Point="89, 180" />
<LineSegment Point="64,70"/>
<LineSegment Point="89,110" />
<LineSegment Point="64,0" />
</PathFigure>
</PathFigureCollection>
</PathGeometry>
</Path.Data>
</Path>
Run Code Online (Sandbox Code Playgroud) 首先,我发现许多问题和许多答案相关或认为与我的问题完全相同,但似乎没有什么对我有用.
我有一个全新的模板MVC4网站,一个全新的安装sql server 2008 r2的数据库.我在数据库上运行aspnet_regsql并创建了我创建的.edmx模型的所有表,该模型在我的web.config中生成了connectionstring.
<connectionStrings>
<add name="TestEntities" connectionString="metadata=res://*/Models.Test.csdl|res://*/Models.Test.ssdl|res://*/Models.Test.msl;provider=System.Data.SqlClient;provider connection string="data source=WEBSRV\SQLEXPRESS;initial catalog=Test;persist security info=True;user id=Test;password=Test#1337;multipleactiveresultsets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
Run Code Online (Sandbox Code Playgroud)
建立网站会返回错误
Unable to find the requested .Net Framework Data Provider. It may not be installed.
我的机器没有自我关闭.<DbProviderFactories/>在我在Visual Studio网站主机或我的网络服务器的IIS上本地运行网站时,会出现同样的问题.我没有安装任何NuGet包
为什么我会收到此错误?
我有一个名为的数据传输对象Report.这些报表对象保存在一个名为的不同类中的可观察集合中Controller.我要做的是创建一个视图,从中获取数据Report并在列表中显示.
我遇到的问题是我似乎无法将视图正确绑定到视图模型.我设法通过使用值转换器并返回我需要的viewmodel来绑定它,但即使视图已附加,Bindings似乎也无法解析.
包含Report列表的viewmodel :
public class ReportListViewModel : Screen, IModule
{
private Controller _controller;
public Controller Controller
{
get { return _controller; }
set { _controller = value; }
}
public ReportListViewModel(Controller controller)
{
Controller = controller;
Controller.Domain.Reports.Add(new Model.Report() { Notes = "Test Data.." });
}
}
Run Code Online (Sandbox Code Playgroud)
以及它的XAML视图:
<Grid Background="Blue">
<StackPanel>
<StackPanel.Resources>
<local:ReportToListItem x:Key="reportToListItem" />
</StackPanel.Resources>
<ListBox Height="100" x:Name="Controller_Domain_Reports">
<ListBox.ItemTemplate>
<DataTemplate>
<ContentControl Content="{Binding Converter={StaticResource reportToListItem}}"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</StackPanel>
</Grid>
Run Code Online (Sandbox Code Playgroud)
价值转换器:
internal …Run Code Online (Sandbox Code Playgroud) 我正在使用此代码获取我的数据并将其推送到Kendo Grid
public ActionResult Read([DataSourceRequest] DataSourceRequest request)
{
return Json(GetData(request), JsonRequestBehavior.AllowGet);
}
private DataSourceResult GetData(DataSourceRequest request)
{
var Items = _db.Item.Local.ToDataSourceResult(request, x => new
{
ID = x.ID,
Title = x.Title,
LastEdited = x.User.LoginName,
Category = x.CategoryItem.Title,
DateEdited = x.DateEdited
});
return Items;
}
Run Code Online (Sandbox Code Playgroud)
在Grid的视图中不使用任何模型,让Grid计算出所有内容.一切正常,我也可以浏览页面.但是,当我添加一个排序方法时,它会抛出这个异常,例如:
Invalid property or field - 'Category' for type: Item
Run Code Online (Sandbox Code Playgroud)
并且每个后续请求都会失败,因为它在DataSourceRequest中具有排序,直到我重新加载页面以清除请求.我是否在配置方面遗漏了一些我需要添加到此代码中的内容?
我在外部提供了一个XML文档,我需要将其导入到我的应用程序中.该文件编写得很糟糕,但不是我真正能做的很多.
<?xml version="1.0" encoding="iso-8859-1"?>
<xml>
<Items>
<Property1 />
<Property2 />
...
</Items>
<Items>
<Property1 />
<Property2 />
...
</Items>
...
</xml>
Run Code Online (Sandbox Code Playgroud)
我应该如何使用XmlSerializer这个?我使用什么类设置似乎并不重要,或者我放在XmlRoot(ElementName="xml")我的基类上它总是说它<xml xmlns=''>是意外的.
编辑:添加了我正在使用的C#代码
[XmlRoot(ElementName = "xml")]
public class Container
{
public List<Items> Items { get; set; }
}
public class Items
{
public short S1 { get; set; }
public short S2 { get; set; }
public short S3 { get; set; }
public short S4 { get; set; }
public short S5 …Run Code Online (Sandbox Code Playgroud) c# ×6
xaml ×4
silverlight ×2
wpf ×2
binding ×1
data-binding ×1
dataprovider ×1
easing ×1
kendo-grid ×1
kendo-ui ×1
web-config ×1
xml ×1