WPF媒体元素视频源(WPF Media Element Video Source)
我尝试在XAML代码中设置视频源,视频无法播放:
<MediaElement x:Name="bgvideo" Width="800" Height="600"Source="/Videos/BG_LOOP_BIG.wmv" />
所以我尝试在代码隐藏中设置视频源,这也不会发挥作用。 :
bgvideo.Source = new Uri(@"pack://application:,,,/Videos/BG_LOOP_BIG.wmv", UriKind.Absolute);
要么
bgvideo.Source = new Uri(@"/Videos/BG_LOOP_BIG.wmv");
它只是在视频源为absoulte时播放:
bgvideo.Source = new Uri(@"C:\SomeFolder\Videos\BG_LOOP_BIG.wmv");
如何设置具有相对来源的视频源?
I try to set video source in XAML code, video doesn't play:
<MediaElement x:Name="bgvideo" Width="800" Height="600"Source="/Videos/BG_LOOP_BIG.wmv" />
So I try to set video source in codebehind, that doesn't play too. :
bgvideo.Source = new Uri(@"pack://application:,,,/Videos/BG_LOOP_BIG.wmv", UriKind.Absolute);
or
bgvideo.Source = new Uri(@"/Videos/BG_LOOP_BIG.wmv");
It just play when video source is absoulte:
bgvideo.Source = new Uri(@"C:\SomeFolder\Videos\BG_LOOP_BIG.wmv");
How can I set video source with relative source?
原文:https://stackoverflow.com/questions/676497
更新时间:2022-09-29 08:09
最满意答案
您可以简单地将范围分配给变量,这将创建一个数组 - 它看起来像下面的代码 - 您应该添加适当的错误处理:
Public Sub FixDates(theRange as Range) Dim data as Variant Dim i as Long Dim j as Long Dim lngDate as Long data = theRange For i = LBound(data, 1) to UBound(data, 1) For j = LBound(data, 2) to UBound(data, 2) If IsNumeric(data(i, j)) Then If data(i, j) > 0 Then lngDate = CLng(data(i, j)) data(i, j) = DateAdd("d", lngDate - 1, "1/1/1968") End If End If Next j Next i theRange = data End Sub
You can simply assign the range to a variant, which will create an array - it would look like the code below - you should add appropriate error handling:
Public Sub FixDates(theRange as Range) Dim data as Variant Dim i as Long Dim j as Long Dim lngDate as Long data = theRange For i = LBound(data, 1) to UBound(data, 1) For j = LBound(data, 2) to UBound(data, 2) If IsNumeric(data(i, j)) Then If data(i, j) > 0 Then lngDate = CLng(data(i, j)) data(i, j) = DateAdd("d", lngDate - 1, "1/1/1968") End If End If Next j Next i theRange = data End Sub
相关问答
更多-
尝试这个 声明一个变量说 Dim oval 和SelectionChange事件中 Public Sub Worksheet_SelectionChange(ByVal Target As Range) oval = Target.Value End Sub 并在您的Worksheet_Change事件集中 old_value = oval try this declare a variable say Dim oval and in the SelectionChange Event Public ...
-
如何更快地为此VBA循环(对于每个单元格,复制粘贴)?(How can I make this VBA loop (for each cell, copy paste) faster?)[2022-12-12]
你可以尝试这样的事情: Dim outputVal As Variant, chkRng As Variant, valRng As Variant Dim i As Long, j As Long, k As Long With rawdata k = .Cells(Rows.Count, 38).End(xlUp).Row chkRng = .Range("Q2:Q" & k).Value valRng = .Range("AL2:AL" & k).Value ReDim outputV ... -
这似乎工作: Private Sub Worksheet_Change(ByVal Target As Range) ' Code to put the date of the latest update following a change in the corresponding cell in column F Dim WorkRng As Range, roww As Long Dim rng As Range Set WorkRng = Intersect(Range("F ...
-
Dim lastRow As Integer: lastRow = 3 Dim myCell As Range 'determine last row of current region Do While(Not IsEmpty(Cells(lastRow + 1, 2))) lastRow = lastRow + 1 Loop 'loop through the range For Each myCell In Range(Cells(2, 2), Cells(lastRow, 2)) m ...
-
将其放置在LookupLists代码部分中(您大概已经这样做了): Private Sub Worksheet_SelectionChange(ByVal target As Range) Dim rng As Range Set rng = Worksheets("LookupLists").Range("Efficient") If Intersect(target, rng) Is Nothing Then Exit Sub Application.EnableEvents = ...
-
Excel:用VBA命名范围(Excel: Named range with VBA)[2023-05-11]
由于您定位了一系列E2:E4,您需要指定单元格位置。 下面的函数可能对您有用,将它传递给列号,例如5,它会重新设置地址,使得5 = E和27 = AA ColLetter = ColNo2ColRef(colNo) Set Rng1 = Sheets("Sheet1").Range(ColLetter & "2:" & ColLetter & "4") ActiveWorkbook.Names.Add Name:="MyRange", RefersTo:=Rng1 Function ColNo2ColR ... -
在进行任何将触发Change事件的Change之前禁用事件: Dim oldCellAddress As String Dim oldCellValue As String Private Sub Worksheet_Change(ByVal Target As Range) oldCellValue = 0 If Not Intersect(Target, Range("E10:E500")) Is Nothing Then Application.EnableEvents ...
-
访问VBA - 更快地更改大范围内的Excel单元格值?(Access VBA - faster way to change Excel cell values across a large range?)[2023-11-23]
您可以简单地将范围分配给变量,这将创建一个数组 - 它看起来像下面的代码 - 您应该添加适当的错误处理: Public Sub FixDates(theRange as Range) Dim data as Variant Dim i as Long Dim j as Long Dim lngDate as Long data = theRange For i = LBound(data, 1) to UBound(data, 1) Fo ... -
您想要的功能是“INDEX”功能。 =INDEX(Homes,1,1) The function you want is the "INDEX" function. =INDEX(Homes,1,1)
-
Do..While , For Each或For i = x to y之间没有时间差异。 如果你想知道如何在每次循环时不进行计算,可以在使用Application.Calculation = xlCalculationManual之后使用Application.Calculation =xlCalculationAutomatic 。 当我说没有区别时,会有很少的,没什么可注意的。 There will be no difference in time between Do..While, For Each ...