我有一個應用程序,由我的前任編寫,使用WPF,但我對它並不十分熟悉。如何在XAML中使用WPF「行爲」?
我不得不接受他編譯的DLL,從this webpage獲取源代碼並將其轉換爲VB,因爲編譯的DLL過去在桌面安裝中工作,拒絕在我們的終端服務器上工作。
因此,我已經採取了C#代碼,並轉換所述
public static class BusyIndicatorBehavior
到
Public Module BusyIndicatorBehavior
我已刪除的頂層名字空間(命名空間ScrumSprintMonitor.UI.Wpf.Behaviors),因爲我真的不知道它應該代表什麼,現在坦率地說,我不知道如何在我擁有的XAML代碼中引用它。
現有的代碼如下:
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="MainWindow"
x:Name="Window"
Title="{Binding Path=WindowTitle}"
UseLayoutRounding="True"
xmlns:l="clr-namespace:myAppName"
xmlns:b="clr-namespace:BusyIndicator;assembly=BusyIndicator" WindowState="Maximized">
<Window.Resources>
<ResourceDictionary Source="ResourceDictionary.xaml" />
</Window.Resources>
<Grid x:Name="LayoutRoot">
<Grid.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FF8B8B8B" Offset="0"/>
<GradientStop Color="#FF484848" Offset="1"/>
</LinearGradientBrush>
</Grid.Background>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid Grid.Column="0" x:Name="grdFolder" b:BusyIndicatorBehavior.BusyState="{Binding Path=BusyState}">
正如你所看到的,以前工作的DLL被稱爲「BusyIndicator.DLL」,與命名空間「b」的引用,然後B由成爲網格的一個屬性。不知何故。奇妙的。
有人可以猜測我如何引用現有項目中的「BusyIndicator」代碼嗎?我意識到我可能已經遺漏了一些重要的信息,但我在這裏很無能。
你是什麼意思?「我現在可以參考現有項目中」BusyIndicator「代碼了嗎?」如果上面的代碼工作,你已經有了一個參考。 – 2011-04-07 11:13:47
對不起,我不清楚。上面的代碼是現有的代碼,它引用了一個DLL。此DLL無法在我們的終端服務器上運行。我已經得到了我認爲是該DLL的源代碼,並將其集成到了我的代碼中。我現在有一些工作(希望)VB代碼,但是非工作XAML必須改變以考慮到BusyIndicator現在對於項目不可或缺的變化。上面的代碼是原始代碼,不起作用。 AUGH! – Frosty840 2011-04-07 11:20:11