小编Dan*_*Lee的帖子

DataGridCheckBoxColumn的WPF绑定未更新

我想弄清楚如何正确处理DataGridCheckBoxColumn.我有一个包含"发布"选项的数据列表.选中时,对象将被标记为发布到其他服务器.到目前为止,我所拥有的是:

<DataGrid x:Name="grdEducationalPopups" 
              HorizontalAlignment="Left" VerticalAlignment="Top"
              Margin="19,155,0,0"                   
              AlternationCount="2"
              AutoGenerateColumns="False"
              ItemsSource="{Binding PopupCollection}"
              Loaded="grdEducationalPopups_Loaded"
              MinRowHeight="26"
              RowDetailsTemplate="{StaticResource RowDetailTemplate}" RowDetailsVisibilityChanged="grdEducationalPopups_RowDetailsVisibilityChanged" SelectionChanged="grdEducationalPopups_SelectionChanged" Grid.ColumnSpan="2">           
        <DataGrid.RowHeaderTemplate>
            <DataTemplate>
                <ToggleButton x:Name="RowHeaderToggleButton" Click="ToggleButton_Click" Cursor="Hand"/>                    
            </DataTemplate>
        </DataGrid.RowHeaderTemplate>
        <DataGrid.Columns>                
            <DataGridTextColumn Width="150" Binding="{Binding DisplayName}" Header="Form Name" IsReadOnly="True"/>
            <DataGridTextColumn Width="280" Binding="{Binding URLLocation}" Header="Page Address"/>
            <DataGridTextColumn Width="125" Binding="{Binding DateLastTouched}" Header="Date Modified" IsReadOnly="True"/>
            <DataGridTextColumn Width="125" Binding="{Binding DateRowAdded}" Header="Date Added" IsReadOnly="True"/>
            <DataGridCheckBoxColumn Header="Publish" Binding="{Binding Path=Publish}">
                <DataGridCheckBoxColumn.CellStyle>
                    <Style>
                        <EventSetter Event="CheckBox.Checked" Handler="OnChecked"/>
                    </Style>
                </DataGridCheckBoxColumn.CellStyle>
            </DataGridCheckBoxColumn>
        </DataGrid.Columns>
    </DataGrid>
Run Code Online (Sandbox Code Playgroud)

我确实有OnClick代码但它现在没有做任何事情,除了允许我检查值.我的发布列表中的值不会更改.false当应该为真时,给定记录的发布值仍然存在.如果我将默认值从false更改为true并启动我的应用程序,则会检查所有复选框,这是我所期望的.这告诉我,我的绑定是正确的.

如何正确管理用户更改,以便我可以适当地处理更改?在我的代码后面我得到一个DataGridCell对象,可以从那里确定行数据,我想编辑那些数据.但我认为绑定数据应该处理这个问题.

c# wpf

3
推荐指数
2
解决办法
3864
查看次数

vbscript 调用函数时出现类型不匹配错误

当我尝试调用我创建的函数时,遇到类型不匹配错误。

例子:

Function DoThis(paramA, paramB, paramC)
    If paramA = "Something" Then
        DoThis = DoSomething
    ElseIf paramA = "This" Then 
        DoThis = DoSomethingDifferent
    Else
        DoThis = DoThisOtherThing   
    End If
End Function
Dim result: result = DoThis(valueA, ValueB, ValueC)
Run Code Online (Sandbox Code Playgroud)

谁能看到我的错误可能是什么?其他功能工作正常。我通过实际复制并粘贴函数名称到我调用的地方来仔细检查拼写。我已经验证函数名称没有在其他地方使用,即作为常量或其他东西。

请注意,调试时所有参数的 ValType 都是 vbString。另外,我永远无法输入该函数,所以这不像我在调试该函数,输入它然后得到类型不匹配。

ty。

vbscript runtime-error

2
推荐指数
1
解决办法
4万
查看次数

附加子目录时,Powershell函数返回双路径

我有一个奇怪的问题。我有一个函数需要$ srcDir和$ destDir和$ topDir $ srcDir的格式为\ $ topDir \ subDir1 \ subDir2 \ subDir..n我需要的是将所有subDir零件附加到$ destDir

到目前为止,我的方法是拆分路径,直到到达$ topDir,然后使用join-path将结果字符串附加到$ destDir。

如果没有子目录附加到$ destPath,则返回结果是完美的。

如果我将路径附加到$ destPath,则返回的是$ destPath $ destPath

这是样本值的输出

  • srcIn:C:\ path \ topdir \
  • destIn:\\服务器\路径\
  • destOut:\\服务器\路径\

现在,如果我有子目录

  • scrIn:C:\ path \ topdir \ subpath \ subpath1
  • destIn:\ server \ path \
  • destOut:\\服务器\路径\子路径\子路径1 \\服务器\路径\子路径\子路径1

在函数内部,路径看起来正确。没有dstOut值的dbl。一旦我从函数返回,它就具有double值。

我该如何预防?我只是想要一个简单的函数来获取子目录并追加到destDir,这样我就可以保留文件夹结构并将文件移动到其适当的目录。

function GetSubDir
{
    param(
        [Parameter(Mandatory=$true)]
        [string]$filePath, 
        [Parameter(Mandatory=$true)]
        [string]$destDir,
        [string]$topDir="Disk1"
    )


    $tmpPath = Split-Path $filePath -parent
    $fileName = Split-Path $filePath -leaf 
    $tmp= Split-Path $filePath -leaf
    while ($tmp -ne $topDir) …
Run Code Online (Sandbox Code Playgroud)

powershell function subdirectory

1
推荐指数
1
解决办法
365
查看次数

标签 统计

c# ×1

function ×1

powershell ×1

runtime-error ×1

subdirectory ×1

vbscript ×1

wpf ×1