我有一个实现可绑定基本如下,请看看他们均绑定了两个按钮,在视图中上移和下移方法视图模型的观察的集合.当按下向上按钮时,我希望数据网格中的选定行在数据库中基于序列列向上移动一步并向下移动一步.两种方法都可以完美地工作.问题是只有在刷新整个视图时才会在数据网格中显示更改.我的要求是单击按钮时我希望视图自动刷新.我为这么长的代码道歉.请帮忙!!!!.我在viewmodel下面指定的向上和向下按钮都有一些cs代码.只需要强调的代码中的指针是ObservableCollection JobEntities,MoveUp和MoveDown命令.
ViewModel.cs:
public class JobConfigurationViewModel : BindableBase
{
    public JobConfigurationLogic JobConfigurationLogic =
        new JobConfigurationLogic(new JobConfigurationResultsRepository());
    public SrcDestConfigurationLogic SrcDestConfigurationLogic =
        new SrcDestConfigurationLogic(new SrcDestCofigurationRepository());
    private string _enterprise;
    public string Enterprise
    {
        get { return _enterprise; }
        set { SetProperty(ref _enterprise, value); }
    }
    private int currentJobID;
    private int currentSequence;
    private int previousJobID;
    private int previousSequence;
    private string _site;
    public string Site
    {
        get { return _site; }
        set { SetProperty(ref _site, value); }
    }
    private int _siteID;
    public int SiteID
    { …我正在使用 Newtonsoft 库 (Json.Net) 从文件中解析 JSON 对象。我在jsonlint.com验证了 JSON ,它是有效的。
但是当我说:
using (StreamReader sr = new StreamReader(path))
{
    json = await sr.ReadToEndAsync();
}
ContactsCollection = JsonConvert.DeserializeObject<List<Contact>>(json); //error
我收到一个错误:
解析值后遇到意外字符:6. 路径 '[0]
所以我放了一个断点,json = await sr.ReadToEndAsync();显示的 JSON 值是:
"\0{\0\"\0F\0i\0r\0s\0t\0N\0a\0m\0e\0\"\0:\0\"\0N\0i\0k\0h\0\"\0,\0\"\0L\0a\0s\0t\0N\0a\0m\0e\0\"\0:\0\"\0A\0N\0S\0\"\0,\0\"\0D\0a\0t\0e\0O\0f\0B\0i\0r\0t\0h\0\"\0:\0\"\01\02\0/\07\0/\01\09\08\09\0 \01\02\0:\00\00\0:\00\00\0 \0A\0M\0\"\0,\0\"\0W\0e\0i\0g\0h\0t\0\"\0:\01\06\08\0.\00\0,\0\"\0H\0e\0i\0g\0h\0t\0\"\0:\01\06\08\0.\00\0,\0\"\0P\0h\0o\0n\0e\0\"\0:\0\"\0(\08\00\05\0)\0 \02\05\01\0-\01\00\01\05\0\"\0}\0]\0"
这是我的实际 JSON:
[{
  "FirstName":"Nikh",
  "LastName":"ANS",
  "DateOfBirth":"12/7/1989 12:00:00 AM",
  "Weight":168.0,
  "Height":168.0,
  "Phone":"(805) 251-1015"
}]
这是我的 Contact 类:
public class Contact : INotifyPropertyChanged
{
    private string _firstName;
    public string FirstName
    {
        get { return _firstName; }
        set
        { …<Button Height="40" Width="40" x:Name="btnup" Command="{Binding UpCommand}" CommandParameter="{Binding ElementName=dgEntities,Path=SelectedItem}" Click="Btnup_OnClick">
这段代码发生的事情是,在OnClick之后执行Command.是否可以先执行Command然后再执行OnClick.请帮忙....
我试图将标签填充到水平滑块上,并且通过将Text传递给FormattedText构造函数,使用从TickBar派生的类成功地做到了这一点。但是现在,当我将相同的代码粘贴到使用.net Framework 4.6.2版的Visual Studio中时,它说:
FormattedText.FormttedText已过时。使用PixelsPerDip替代。
我在.NET Framework 4.6.2中提到过FormattedText()已过时,我该如何修复
但是在当前情况下我该如何使用它。请帮忙。
FormattedText formattedText = new FormattedText(text, CultureInfo.GetCultureInfo("en-us"), FlowDirection.LeftToRight, new Typeface("Verdana"), 16, Brushes.Black);
dc.DrawText(formattedText, new Point((tickFrequencySize * i), 30)); //dc is Drawing Context.
这是完整的课程
public class CustomTickBar : TickBar
    {
        public static string FontTextList { get; set; }
        protected override void OnRender(DrawingContext dc)
        {
            //string str = "Small, Medium, Large, Extra\n Large";
            if (!string.IsNullOrEmpty(FontTextList))
            {
                string[] ar = FontTextList.Split(',');
                Size size = new Size(base.ActualWidth, base.ActualHeight);
                int tickCount = (int)((this.Maximum - …正如我的帖子所建议的,我在 StackOverflow 上看到了一篇帖子,用于在 xaml 中的 TextBox 文本为空时禁用按钮。但问题是,每当用户按下空格键而不输入任何字符时,该按钮就会启用。如果 xaml 本身的 TextBox 中只有空格而没有任何文本,是否可以禁用该按钮。
<TextBox x:Name="txtReasonForChange" Grid.Row="0" Grid.Column="1" TextWrapping="Wrap" ScrollViewer.VerticalScrollBarVisibility="Auto"></TextBox>
 <Button x:Name="btnSaveOrSaveAs" Grid.Row="2" Grid.Column="1" IsEnabled="{Binding ElementName=txtReasonForChange,Path=Text.Length}" HorizontalAlignment="Right" Click="btnSaveOrSaveAs_Click"></Button>
我有一个名为 InstrumentConfigValues 的类,其属性具有实现接口的类型。现在我有一个名为 InstrumentConfig 的枚举,它具有一组值。这些值就像 json 文件中的键。我想映射类似[JsonProperty(InstrumentConfig.LowDiskpace.ToString()].
出于某种原因,它不允许这样做并抱怨说:
属性参数必须是常量表达式
我特别提到了许多帖子JsonStringEnumConverter。但是如何使用枚举键映射每个属性。我也看到了这篇文章JsonSerializationSettings但无法与我的问题相关联。请帮忙/
public class InstrumentConfigValues : IInstrumentConfig
{      
    public double SpaceNeededForSingleRun
    {
        get; set;
    }
    public int NumberOfInputSlots
    {
        get; set;
    }
    public int SupportedChannelCount
    {
        get; set;
    }
}
//I want this inheritance as some other class wants to access the values.
public abstract class InstrumentConfigReadWrite : InstrumentConfigValues
{
    protected ReturnCodes PopulateValuesFromJObject(JObject jObject, string path)
    {
        try
        {
            if (JsonConvert.DeserializeObject<InstrumentConfigValues>(jObject.ToString()) == null)
            {
                return ReturnCodes.ErrorReadingFile; …我有一个按钮,其中enabled属性应该发生两次。在视图模型中,如果IsEnabled属性设置为false,则应禁用该按钮,这样效果很好。另一方面,当禁用UI中的“验证”按钮时,也应禁用该按钮,该按钮不起作用,这表示数据触发器不起作用。请帮忙。
<Button x:Name="BtnValidate" Content="Validate" Height="24" VerticalAlignment="Top" Grid.Column="2" Width="83" Command="{Binding ValidateCommand}" IsEnabled="{Binding IsValidateEnabled}" HorizontalAlignment="Left" Margin="8,28,0,0" />
    <Button Name="BtnReload" IsEnabled="{Binding IsEnabled}" HorizontalAlignment="Left" Width="123" Grid.Row="0" Grid.Column="5" Content="Reload" Command="{Binding DateCommand}" Margin="8,24,0,32">
                        <Button.Style>
                            <Style TargetType="Button">
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding ElementName=BtnValidate,Path=IsEnabled}" Value="False">
                                        <Setter Property="IsEnabled" Value="False"></Setter>
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </Button.Style>
                    </Button>