我的计算机上有两个计划任务.它们都打开excel文件并运行宏,并且与它们的功能非常相似.它们都在我的电脑上工作.但是我将计划的任务移到同事计算机上.一个人工作,另一个人没有.
没有工作的那个开了excel但是有一个错误说:
"对可视化基础项目的编程访问不受信任".
就像我说两个excel文件非常相似.没有工作的那个确实引用了另外两个项目,而另一个没有.他们是,
Microsoft Visual Basic for Applications Extensibility 5.3
Microsoft Windows Common Controls-2.6.0 (SP6)
Run Code Online (Sandbox Code Playgroud)
我之前从未遇到过这个错误.
我有一个存储过程,它接受两个参数.我可以在Server Management Studio中成功执行它.它向我展示了我期望的结果.但是它也会返回一个返回值.
它增加了这条线,
SELECT 'Return Value' = @return_value
Run Code Online (Sandbox Code Playgroud)
我希望存储过程返回它在结果中显示的表而不是返回值,因为我从MATLAB调用此存储过程并且它返回的全部为true或false.
我是否需要在我的存储过程中指定它应该返回什么?如果是这样,我如何指定一个包含4列的表(varchar(10),float,float,float)?
在我的WPF应用程序中,我试图根据用户选择的选项更改按钮的可见性.在加载时,我希望其中一个按钮不可见.我正在使用内置值转换器BooleanToVisibilityConverter.然而,由于按钮在加载时出现,因此无法正常工作.我已将属性更改为true和false,没有任何区别.下面是我的代码,我看不出我错过了什么?
我的View模型中的属性
bool ButtCancel
{
get { return _buttCancel; }
set
{
_buttCancel = value;
OnPropertyChanged("ButtCancel");
}
}
Run Code Online (Sandbox Code Playgroud)
在我的app.xaml中
<Application.Resources>
<BooleanToVisibilityConverter x:Key="BoolToVis"/>
Run Code Online (Sandbox Code Playgroud)
在我的MainWindow.xaml中
<Button Grid.Column="2"
Command="{Binding CommandButtProgressCancel}"
Content="Cancel"
Visibility="{Binding ButtCancel, Converter={StaticResource BoolToVis}}"
IsEnabled="{Binding ButtCancelEnabled}"
Height="50" Width="120"
HorizontalAlignment="Center"
VerticalAlignment="Center" Margin="0,0,50,20"/>
Run Code Online (Sandbox Code Playgroud) 我的WPF应用程序中有一个列表框.我知道如何使用selectionchanged事件.但是我试图遵循MVVM设计.但是我不知道该怎么做.
我已经为一个按钮做了这个,但不确定我是否可以做同样的事情?
<Button Grid.Column="0" Name="buttImport"
Content="Import File"
Command="{Binding CommandButtImport}"
Style="{StaticResource ButtonTemplate}"/>
Run Code Online (Sandbox Code Playgroud)
public class ViewModel : INotifyPropertyChanged
{
// for the button that imports the orders file
public ICommand CommandButtImport { get; set; }
public ViewModel()
{
CommandButtImport = new MyCommands(
ExecuteCommandButtImport,
CanExecuteCommandButtImport);
}
private bool CanExecuteCommandButtImport(object parameter)
{
return true;
}
// import button
private void ExecuteCommandButtImport(object parameter)
{
// some code
}
}
Run Code Online (Sandbox Code Playgroud)
编辑请忽略上面的代码
我已经更改了我的代码,所以在我目前拥有的内容之下重新发布.我有一个奇怪的问题.XAML - 主代码包含我的数据网格的代码.App - XAML下面的块包含我的大多数应用程序的样式,但只是一个snipet.
也
代码行添加到我的数据网格下面的XAML - 主代码中用于测试目的.
<ListBox ItemsSource="{Binding SelectedItem.DuplicateSecurities, ElementName=dataGridOrders}"
SelectedItem="{Binding …
Run Code Online (Sandbox Code Playgroud) 我认为这将是相当简单的,可能是但我在谷歌上找不到任何东西.我有一个WPF应用程序,其数据网格绑定到我的对象,其中包含bool,string和int类型的属性.显示int我想显示30,000而不是30000.这是怎么回事?
任何帮助都会很棒,谢谢,M
我有两个列表,我想比较.所以我创建了一个实现IEqualityComparer
接口的类,请参见下面的代码底部.
当我单步GetHashCode
执行代码时,代码会通过我的实现而不是Equals
?GetHashCode
尽管在互联网上阅读以及它到底在做什么,但我并不真正理解这种方法.
List<FactorPayoffs> missingfactorPayoffList =
factorPayoffList.Except(
factorPayoffListOrg,
new FactorPayoffs.Comparer()).ToList();
List<FactorPayoffs> missingfactorPayoffListOrg =
factorPayoffListOrg.Except(
factorPayoffList,
new FactorPayoffs.Comparer()).ToList();
Run Code Online (Sandbox Code Playgroud)
所以在上面的两行代码中,两个列表返回每个项目,告诉我这两个列表不包含任何相同的项目.事实并非如此,只有不同的行.我猜这种情况正在发生,因为该Equals
方法没有被调用,这反过来让我想知道我的GetHashCode
方法是否正常运作?
class FactorPayoffs
{
public string FactorGroup { get; set; }
public string Factor { get; set; }
public DateTime dtPrice { get; set; }
public DateTime dtPrice_e { get; set; }
public double Ret_USD { get; set; }
public class Comparer : IEqualityComparer<FactorPayoffs>
{
public bool Equals(FactorPayoffs x, FactorPayoffs y)
{ …
Run Code Online (Sandbox Code Playgroud) 所以,我有一个数据网格,根据单元格的值,它具有不同的颜色单元格.
我还有一个工具提示,显示一些进一步的信息.一切正常.
但是,我想改变工具提示以显示更多信息,并且还要与单元格颜色相同.所以,我认为为我的工具提示创建自定义样式是明智的.所以,我有以下代码.
<Style TargetType="ToolTip">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ToolTip">
<Border CornerRadius="15,15,15,15"
BorderThickness="3,3,3,3"
Background="#AA000000"
BorderBrush="#99FFFFFF"
RenderTransformOrigin="0.5,0.5">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="2*"/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0"/>
<TextBlock Grid.Row="1"/>
<TextBlock Grid.Row="2"/>
</Grid>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Run Code Online (Sandbox Code Playgroud)
我有一个如下所示的对象绑定到我的datagrid.我想将三个属性绑定到工具提示中的三个文本框.
class MyTask
{
public string Name;
public int Code;
public string Description;
}
Run Code Online (Sandbox Code Playgroud)
在我的DataGrid中,我执行以下操作将数据绑定到datagrid
ItemsSource="{Binding TaskList}"
Run Code Online (Sandbox Code Playgroud)
然后在DataGridTextColumn中我绑定到如下所示的属性
DataGridTextColumn Header="Code" Binding="{Binding Code}"
Run Code Online (Sandbox Code Playgroud)
这对我来说很有意义.然而,在创建自定义工具提示时,我无法看到我如何使用绑定.我读过我可以使用templatebinding.我仍然不明白我的工具提示将如何绑定到我的xaml上面的MyTask类型的对象?
更新 - 希望让我的问题更清晰
我想知道如何在我的控件模板(对于3个文本框)中创建绑定,然后在我的代码的主要部分中如何绑定到这些文本框.然后我想知道如何为我的控件模板的背景颜色创建一个绑定,我相信这与relativesource有关吗?
当我正在阅读其他示例(更改模板属性)时,我会看到如下所示的行.我真的不明白你为什么要这么做?如果你没有在下面的行右边,你将无法在Padding属性上创建绑定吗?
<Border Padding="{Binding Padding}" ...>
Run Code Online (Sandbox Code Playgroud) 我有一个包含网格的WPF应用程序.网格被分成3列,第3个网格在加载时具有零宽度.
我在另外两列中有两个数据网格.当其中一个datagrid中的所选项更改时,其他datagrid会更改其显示值,即主详细信息模板.一切正常.
数据网格中有一个值,如果选中,我希望第3列将其宽度从零更改为2*.我不知道怎么做?
我希望通过XAML实现这一目标.我一直在关注数据触发器和值转换器.我在下面快速编写了一些代码进行测试.我已经读过将列设置为width = 0,依赖项属性设置优先级列表中可能更高.无论如何要做到这一点还是我需要使用代码?
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="0"/>
</Grid.ColumnDefinitions>
<DataGrid Grid.Column="0"
ItemsSource="{Binding OrderList}"
SelectedItem="{Binding OrderSelected}"
AutoGenerateColumns="True">
</DataGrid>
<TextBox Grid.Column="1" Text="{Binding OrderSelected.Name}">
</TextBox>
<Grid x:Name="columnHideSeek" Grid.Column="2" Background="Blue">
<Grid.Style>
<Style>
<Style.Triggers>
<DataTrigger Binding="{Binding OrderSelected.Name}" Value="Mark">
<Setter Property="Grid.Width" Value="10"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Grid.Style>
</Grid>
</Grid>
Run Code Online (Sandbox Code Playgroud) 我希望能够遍历chrome页面上的所有选项卡并关闭任何youtube页面的选项卡.
我做了一些谷歌搜索并找到了下面的代码.有两个(可能更多)问题.首先,我创建了一个WPF应用程序并添加了System.Windows.Automation命名空间(使用visual studio 2015 .net 4.5),但无法识别AutomationElement.
此外,我不确定如何循环选项卡并测试页面是否是youtube页面.
Process[] procsChrome = Process.GetProcessesByName("chrome");
if (procsChrome.Length <= 0)
return null;
foreach (Process proc in procsChrome)
{
// the chrome process must have a window
if (proc.MainWindowHandle == IntPtr.Zero)
continue;
// to find the tabs we first need to locate something reliable - the 'New Tab' button
AutomationElement root = AutomationElement.FromHandle(proc.MainWindowHandle);
var SearchBar = root.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.NameProperty, "Address and search bar"));
if (SearchBar != null)
{
AutomationPattern[] patterns = SearchBar.GetSupportedPatterns();
if(patterns.Length > 0)
{ …
Run Code Online (Sandbox Code Playgroud) 我有一个WPF应用程序.我有一些标签和一些数据网格绑定到一些公共属性.其中一些属性是数值.
在datagrids中,我一直在使用下面的行来确保这些值只显示两个小数位,这是有效的.但是,当我使用下面相同的行作为我的标签时,它似乎对显示没有影响,因为数字显示为大约9位小数.我不明白为什么它适用于datagrid但不适用于标签?
StringFormat={}{0:0.##}
<Label Grid.Row="3" Grid.Column="1"
Content="{Binding Obs.Tstat, StringFormat={}{0:0.#}}"
HorizontalAlignment="Center" Foreground="{StaticResource brushLinFont}"
FontSize="13" FontWeight="Bold"/>
Run Code Online (Sandbox Code Playgroud)
更新的代码
<Label Grid.Row="3" Grid.Column="1"
Content="{Binding Obs.Tstat}" ContentStringFormat="{}{0:0.#}}"
HorizontalAlignment="Center" Foreground="{StaticResource brushLinFont}"
FontSize="13" FontWeight="Bold"/>
Run Code Online (Sandbox Code Playgroud)