我TreeView在 wpf 中有一个如何获取TreeView节点单击事件以便我可以获得用户单击的节点的值?
<Grid Height="258" Width="275">
<TreeView Height="258" HorizontalAlignment="Left" Name="treeView1" VerticalAlignment="Top" Width="275">
</TreeView>
</Grid>
Run Code Online (Sandbox Code Playgroud)
我已经TreeView从 C# 代码填充了它。我需要在 C# 代码中写入什么事件方法才能获取用户在我的 C# 代码中单击的节点的值。
TreeViewItem treeItem = null;
treeItem = new TreeViewItem();
treeItem.Header = "Name";
Run Code Online (Sandbox Code Playgroud) 您如何使用PowerShell对此文件名列表进行排序,以便它们以降序版本顺序显示?
我只需要最高版本的文件名.
Name
----
CYFS_PreK_1_0_1_10
CYFS_PreK_1_0_1_11
CYFS_PreK_1_0_1_12
CYFS_PreK_1_0_1_13
CYFS_PreK_1_0_1_14
CYFS_PreK_1_0_1_15
CYFS_PreK_1_0_1_16
CYFS_PreK_1_0_1_17
CYFS_PreK_1_0_1_18
CYFS_PreK_1_0_1_19
CYFS_PreK_1_0_1_20
CYFS_PreK_1_0_1_21
CYFS_PreK_1_0_1_22
CYFS_PreK_1_0_1_23
CYFS_PreK_1_0_1_8
CYFS_PreK_1_0_1_9
Run Code Online (Sandbox Code Playgroud)
以下将选择"CYFS_PreK_1_0_1_9",因为它是按字母顺序排列的最高数字,因为版本号中没有前导零.
$lastVersion = get-childitem $src |
sort-object -descending |
select-object -First 1 -Property:Name
Run Code Online (Sandbox Code Playgroud)
但是,我正在寻找"CYFS_PreK_1_0_1_23"
更新:
如果我们只关心最后一组数字,我们可以拆分下划线的名称,并以数字方式对最终段进行排序.
Get-ChildItem $_ |
Sort-Object {[int] $_.Name.Split("_")[5]} -Descending |
select-object -First 1 -Property:Name
Run Code Online (Sandbox Code Playgroud)
这适用于此集合,但是,如果我们转换为版本1_0_2_x,则它会再次中断,因为1_0_2_1中的最后1在1_0_1_23中小于23.
我有一个 TreeListControl 绑定到我的虚拟机中的一个集合。我还想在树列表控件内定义上下文菜单,使其标题文本绑定到虚拟机中的另一个字符串。在这种情况下如何设置数据上下文?我尝试过了
<Window.DataContext>
<model:ViewModel></model:ViewModel>
</Window.DataContext>
<Grid>
<Button Grid.Row="1" Command="{Binding CellCheckedCommand}"></Button>
<TextBlock Text="{Binding HeaderText}" Grid.Row="2">
<TextBlock.ContextMenu>
<ContextMenu>
<MenuItem DataContext="{Binding RelativeSource={RelativeSource AncestorType={x:Type Window}}, Path=DataContext}" Header="{Binding HeaderText}"></MenuItem>
</ContextMenu>
</TextBlock.ContextMenu>
</TextBlock>
</Grid>
Run Code Online (Sandbox Code Playgroud)
但它不起作用。
这是视图模型
public DelegateCommand CellCheckedCommand { get; set; }
private String _HeaderText;
public String HeaderText
{
get
{
return _HeaderText;
}
set
{
_HeaderText = value;
NotifyPropertyChanged("HeaderText");
}
}
public void NotifyPropertyChanged(String name)
{
if(PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(name));
}
}
private void CellCheckedMethod()
{
HeaderText = "Changed";
}
Run Code Online (Sandbox Code Playgroud) 我在 Blazor 应用程序中使用 Mudblazor。我在 ValidSubmit 处理程序内的组件中有以下代码:
public async Task HandleValidSubmit()
{
DialogService.Show<SavingDialog>("Saving Data");
await Http.PostAsJsonAsync("api/Client/AddClient", CModel);
//close the dialog here...
//DialogService.Close(<need reference here>);
}
Run Code Online (Sandbox Code Playgroud)
打开DialogService它SavingDialog也是一个组件。http 调用后,我想关闭对话框。我怎么做?DialogService.Close(DialogReference dialog)我可以在文档中看到。
如何获取对我打开的对话框的引用以便将其关闭?
默认的 SQL Server 日志目录在我的 C 驱动器上已满。如何移动SQL Server错误日志默认目录?
我困惑之间SPSite,SiteCollection和SPWeb?
所以我的理解是这个伪代码:
http://My_server >>> TOP Level SIte or SPWEbApplication
http://My_server/My_site >>>> Site Collection or SPSite
Run Code Online (Sandbox Code Playgroud)
现在SPSite,将引用其下的网站SPWeb.那么我们在使用时会得到什么SPWeb.Webs?
什么是子网站?
测试代码:
SPWeb mySite = SPContext.Current.Web;
SPWebCollection sites = mySite.Webs;
foreach (SPWeb subSite in sites)
{
Response.Write(SPEncode.HtmlEncode(subSite.Title) + "<BR>");
}
Run Code Online (Sandbox Code Playgroud) 我在db中有一个列偏移量,varchar(50)其中包含一个诸如05:30:00或的值-2:15:00.
我需要从另一个DATETIME数据类型的列中添加或减去此值2011-07-22 14:51:00.
我正在学习WPF并且不确定最好的方法是什么; 我有一个员工ID和与该员工关联的图像作为项目中的资源(图像显示在员工姓名旁边的列表中).
所以我觉得这样的事情
<DataTemplate DataType="{x:Type m:Employee}">
<Grid>
<Image Grid.Column="0" Name="image" Source="../Images/{Binding Path=Id}.jpg"/>
Run Code Online (Sandbox Code Playgroud)
它不是有效的XAML.
我想我可以在代码隐藏中处理一些数据绑定事件并在那里创建路径?对我来说似乎不太理想.
我可以在我的Employee类中存储路径,但这很糟糕.
谢谢
我正在尝试创建一个通用接口,它允许我使用与数据库交互的方法.我希望我的业务应用程序能够实例化任何连接方法,并确保接口是相同的.
这是我现在正在尝试的简化版本.
数据库接口,其中IElement是另一个定义表的接口.
public interface IDatabase
{
void setItem( IElement task ); //this works fine
List<T> listTasks<T>() where T : IElement; // this doesn't
}
Run Code Online (Sandbox Code Playgroud)
IElement界面:
public interface IElement
{
int id { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
IElement的实施:
public class TaskElement: IElement
{
public int id { get; set; }
public string name {get; set; }
}
Run Code Online (Sandbox Code Playgroud)
IDatabase的实现:
public class SQLiteDb: IDatabase
{
public SqLiteDb( SQLiteConnection conn )
{
database = conn;
}
public void setItem( IElement task …Run Code Online (Sandbox Code Playgroud) 我有一个这样的字符串:
string myText = "abc def ghi 123 abc def ghi 123 abc def";
Run Code Online (Sandbox Code Playgroud)
我只想abc用空替换最后一个。
这是我的代码:
string pattern2 = "([abc])$";
string replacement2 = "";
Regex regEx = new Regex(pattern2);
var b = Regex.Replace(regEx.Replace(myText, replacement2), @"\s", " ");
Run Code Online (Sandbox Code Playgroud)
它不能正常工作,那么如何才能做到呢?
c# ×3
wpf ×3
sql-server ×2
binding ×1
blazor ×1
c#-4.0 ×1
data-binding ×1
datacontext ×1
dialog ×1
generics ×1
interface ×1
mudblazor ×1
powershell ×1
reference ×1
regex ×1
sharepoint ×1
sql ×1
treeview ×1