|
Hi All,
I recently started working on a new project. One of my first tasks was to make the modules load dynamically. Basically the client would download the shell xap then when they required another module this modules xap file would be downloaded. Doing this doesn't force the user to download one massive xap file and therefore improve performance. I have this working without too much trouble however the problem I have is that once on the client I have no reference to the xap file that I have downloaded unless I hard code something. So at the moment I have solved this by creating an AvailableApplicationModule.shared.cs file which contains a list of all dynamic modules in the solution, then in the bootstrapper these are loaded into the module catalog. E.g.
public static ApplicationModuleInfo SampleModule
{
get
{
return new ApplicationModuleInfo
{
ModuleName = "SampleModule",
ModuleType = GetModuleTypeForModule("SampleModule", "SampleModuleModule"),
InitializationMode = InitializationMode.OnDemand,
Ref = "Example.UI.SampleModule.xap"
};
}
}
The GetModuleTypeForModule will return the Fully qualified name like:
Example.UI.SampleModule.SampleModuleModule, Example.UI.SampleModule, Version=1.1.0.0, Culture=neutral, PublicKeyToken=537c3450b3658434
Then in the client tier I can access the module catalog get the typename and then create an instance of this ModuleType which will then initialise itself. Unfortunatly by doing this I have to specify a build version.
Now this is fine on a local machine as I can just override the build targets to force the version to 1.1.0.0 however once I commit this to TFS the actual build number will be used. Since I have to construct this fully qualified name in code it'll break as instead of getting 1.1.0.0 it'll be something like 1.0.15.1345. Which it won't be able to find as I need to specify the version number in code.
I guess this is a common problem so I'm just looking for some adivce on how you guys handle this?
Not sure if this is relevant but I'm using PRISM and Castle as the container.
Thanks
Phil
|
|
|
|
|
Hello,
Im writing an application which will be a host for different plug in DLL's.
I think im want to use the MAF model.
My application will have some set of asynchronous events.
I want the different plug in DLL's will have the option to "sign" on some of thoose events(maybe none) and execute some calback function when the event fires.
So far i already know that the API's that the plug in will implement are defined in abstract class that derives from IContract.
But what is the way to define the events,events handlers and some costum variables that have to be serializable.
Thanks.
|
|
|
|
|
Rather than using MAF, you might want to take a look at using MEF. This is a much simpler beast to use altogether, and is really cool to develop against.
|
|
|
|
|
Hello,
Ok does MEF give me the options to do what i listed above?
|
|
|
|
|
|
Hi,
How to navigate between xaml page from aspx page.
eg:
I have two XAML page A.XAML and B.XAML. In the .web project, i have an ASPX page with two linkbutton, when i click the first linkbutton i need to open A.XAML, when click on second linkbutton i need to open B.XAML
Thankyou
YPKI
|
|
|
|
|
yesu prakash wrote: I have two XAML page A.XAML and B.XAML. In the .web project, i have an ASPX page with two linkbutton, when i click the first linkbutton i need to open A.XAML, when click on second linkbutton i need to open B.XAML
If you are using Silverlight, then you will need to load the xap file that is built using the two xamls.
Once the xap file is loaded, you can choose which xaml page to load in your web page (via Silverlight code).
Too much of heaven can bring you underground
Heaven can always turn around
Too much of heaven, our life is all hell bound
Heaven, the kill that makes no sound
|
|
|
|
|
Hello
Help me please
I want create game on windows phone game XNA
which about quiz
the fist screen I want tow option first for picture second for word
the player choose one quiz when the player choose picture will appear picture and the player name the picture on text box for example, if the picture about apple the player write apple if correct will give player 5 point if not will loose 5 point
I do not know how I can start
just show me how can I start
Please I need it
Help me T_T
Thank you
|
|
|
|
|
|
Thank you
I read the example but I cannot do my quiz
if you help me just how can I start
I thank you very much
please just show me
best regards
|
|
|
|
|
That article shows you how you can use XNA on a Windows 7 phone, if you don't understand it, then I'm sorry to say you have to forget about this and go back to basics.
No I can't just show you how to implement your requirements, if you don't want to do your own work then you're on the wrong site. There are plenty of sites out there where you can PAY developers to create your software.
I'm offering my help and advise on this site, because I like doing that, but that doesn't mean I'm gonna do charity work for people.
My number one dev tool? Google
|
|
|
|
|
Anyway Thank you for comment
|
|
|
|
|
Well done for this reply. That was a mature and considered response, and I'd like to welcome you to Code Project.
|
|
|
|
|
Hello,
I am searching for inspiration ...
I'm currently building an business application using Silverlight.
To be honest, this is my first "proper" UI project in a long time, and I have had to do a lot of technology catchup - EF, MVVM, Prism, MEF/Unity - the list is endless - and I just hope that I'm on the right track ...
Part of the requirment is to enable the administrator to add custom defined fields the core entities within the application. these fields will change between customers - so it needs to be data driven. For example, a particular customer may have a requirement for certain bespoke finanacial fields on a Order header.
these custom fields would then be rendered at runtime into the SL page - and support all of the usual validation rules.
The sort of functionality I'm looking for is similar to the custom lists you get in sharepoint. I had considered using (or integrating into) sharepoint - but then this give me an added dependency that I did not want.
I am capabable of developing this whole framework myself, but before I dive-in, I thought I would ask to wider community if anyone is aware of any similar framework that would offer all (or part) of the functionality that I'm looking for.
Regards,
Gary.
|
|
|
|
|
Have you considered looking into Visual Studio Lightswitch? It sounds like it could be exactly what you want. See here[^].
|
|
|
|
|
I am using VS2008 and Silverlight 3. In a data form, I want to put some validation (like name can't be blank, age can't be <= 0)against save button. Error message will be display in a validation summary and textbox will marked by red.
Please help me.
|
|
|
|
|
|
I have a textblock and a slider* that are both bound to the same value of an object. The value actually represents a physical measurement coming from a device and it's nominally should be between 0 and 400. The problem is that the actual value read my go above or below that value (somewhere from about -5 to 450). This wasn't a problem in WPF, the slider just ignored values above and below the max and min, but in Silverlight it does something rather strange. It appears that if the value being bound to a slider goes above or below the max and min of the slider, the slider simply throws up it's hands (figuratively) and just stops binding. What gives? Is that normal behavior for the slider in Silverlight? I searched, but could find anything online that seems related.
I guess I could just have another property to my class that shadows the real value but caps it at the max and min of the slider, but that seems like an ugly hack around.
(* note: both are using one-way binding and are being used as indicators, not input controls - there are separate controls for that which have their own problems!)
|
|
|
|
|
i would add a binding converter to check and repairs the range if needed (IValueConverter)
or if that is over kill use a FallbackValue
|
|
|
|
|
Yes a converter is what I would go for too, assuming that the OP has already checked with a simple test example that the slider really is dropping the binding if it receives an invalid value.
|
|
|
|
|
Here's a simple test for you:
<UserControl x:Class="SLSliderDemo.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local ="clr-namespace:SLSliderDemo"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">
<UserControl.Resources>
<local:Data x:Key="data"/>
</UserControl.Resources>
<StackPanel x:Name="LayoutRoot" Background="White" DataContext="{StaticResource data}">
<Slider Minimum="0" Maximum="10" Value="{Binding CurrentValue, Mode=OneWay}" IsEnabled="False"/>
<TextBlock Text="{Binding CurrentValue, StringFormat=Current Value \{0\}}"/>
<TextBox Text="{Binding CurrentValue, Mode=TwoWay}"/>
<TextBox/>
</StackPanel>
</UserControl>
And the data class:
namespace SLSliderDemo
{
public class Data : INotifyPropertyChanged
{
private double currentValue;
public double CurrentValue
{
get { return currentValue; }
set
{
currentValue = value;
OnPropertyChanged("CurrentValue");
}
}
#region INotifyPropertyChanged Members
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
#endregion
}
}
Run the demo - type 5 in the first text box. Slider moves half way, text block shows 5. Set the first text box to 7. Slider moves, text block shows 7. Set the first text box to 11. Slider moves to the end, text block shows 11. Set the first text box back to 2. Text block shows 2, slider is now stuck at 10.
|
|
|
|
|
Thanks. I think that would probably work. I did the shadow value thing, but I think a converter might be more MVVMish since I could abstract away from my MV worrying about what exactly the max and min values of the slider are. I could pass them as parameters instead.
Its just annoying that the Silverlight slider works that way. I guess it because of the lack of coercion support for dependency properties in Silverlight.
modified 30-Sep-11 16:09pm.
|
|
|
|
|
I had a working example of a combobox jumping to the correct selecteditem based on the choice of another combobox but I can't seem to make it work with a very simple example. I'll try to keep the code to a minimum but I don't see why a choice in "product" will not cause the correct "category" to be selected. This same code seemed to work fine when working with an EF data model based on the NW database.
Main window
<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="400" Width="1200">
<Grid Width="900" HorizontalAlignment="Left" DataContext="{Binding}">
<Grid.RowDefinitions>
<RowDefinition Height="44*" />
<RowDefinition Height="44*" />
<RowDefinition Height="44*" />
<RowDefinition Height="256*" />
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Margin="5,0,0,0" FlowDirection="LeftToRight" Orientation="Horizontal" VerticalAlignment="Top" HorizontalAlignment="Left" >
<TextBlock Text="Select a Product" Margin="5"></TextBlock>
<ComboBox Height="28" Name="cmbProducts2" Width="150" Margin="3"
IsEditable="False"
ItemsSource="{Binding Path=myProductList, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"
SelectedItem="{Binding mySelectedProduct}"
>
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" >
<TextBlock Text="{Binding Path=ProductName}" />
<TextBlock Text=" (" />
<TextBlock Text="{Binding Path=ProductID}" />
<TextBlock Text=") " />
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ComboBox>
</StackPanel>
<StackPanel Grid.Row="1" Margin="5,0,0,0" FlowDirection="LeftToRight" Orientation="Horizontal" VerticalAlignment="Top" HorizontalAlignment="Left" >
<TextBlock Text="Category Should Auto Select" Margin="5"></TextBlock>
<ComboBox Height="28" Name="cmbCategory2" Width="150" Margin="3" IsEditable="False"
ItemsSource="{Binding Path=myCategoryList, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"
SelectedItem="{Binding mySelectedCategory}"
>
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" >
<TextBlock Text="{Binding Path=CategoryName}" />
<TextBlock Text=" (" />
<TextBlock Text="{Binding Path=CategoryID}" />
<TextBlock Text=") " />
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ComboBox>
</StackPanel>
<StackPanel Grid.Row="2" Margin="5,0,0,0" FlowDirection="LeftToRight" Orientation="Horizontal" VerticalAlignment="Top" HorizontalAlignment="Left" >
<TextBlock Text="mySelectedCategory.CategoryName=" />
<TextBlock Text="{Binding mySelectedCategory.CategoryName}" Foreground="#FFFC0000"/>
<TextBlock Text=" mySelectedCategory.CategoryID=" />
<TextBlock Text="{Binding mySelectedCategory.CategoryID}" Foreground="#FFFC0000"/>
</StackPanel>
<StackPanel Grid.Row="3" Margin="5,0,0,0" FlowDirection="LeftToRight" Orientation="Horizontal" VerticalAlignment="Top" HorizontalAlignment="Left" >
<TextBlock Text="mySelectedProduct.myCategory.CategoryName=" />
<TextBlock Text="{Binding mySelectedProduct.myCategory.CategoryName}" Foreground="#FFFC0000" ForceCursor="True"></TextBlock>
<TextBlock Text=" mySelectedProduct.myCategory.CategoryID=" />
<TextBlock Text="{Binding mySelectedProduct.myCategory.CategoryID}" Foreground="#FFFC0000"/>
</StackPanel>
</Grid>
</Window>
Data repository
Imports System.Collections.ObjectModel
Public Class myDataRepository
Private _mycateorylist As ObservableCollection(Of myCategory)
Public Sub New()
_mycateorylist = New ObservableCollection(Of myCategory)
_mycateorylist = GetMyCategories()
End Sub
Public Function GetMyProducts() As ObservableCollection(Of myProduct)
Dim a As New myProduct()
Dim b As New myProduct
Dim c As New myProduct
Dim d As New myProduct
a.ProductID = 1
a.ProductName = "tire"
a.CategoryID = 1
b.ProductID = 2
b.ProductName = "wipers"
b.CategoryID = 1
c.ProductID = 3
c.ProductName = "tv"
c.CategoryID = 2
d.ProductID = 4
d.ProductName = "radio"
d.CategoryID = 2
Dim list As New List(Of myProduct)
list.Add(a)
list.Add(b)
list.Add(c)
list.Add(d)
Return New ObservableCollection(Of myProduct)(list)
End Function
Public Function GetMyCategories() As ObservableCollection(Of myCategory)
Dim a As New myCategory
Dim b As New myCategory
a.CategoryID = 1
a.CategoryName = "auto"
b.CategoryID = 2
b.CategoryName = "electronics"
Dim list As New List(Of myCategory)
list.Add(a)
list.Add(b)
Return New ObservableCollection(Of myCategory)(list)
End Function
Public Function GetMyCategory(ByVal id As Int32) As myCategory
Dim results = From c In _mycateorylist
Where c.CategoryID = id
Select c
Dim rs As IEnumerable(Of myCategory) = From x In results.AsEnumerable
Select New myCategory With
{
.CategoryID = x.CategoryID,
.CategoryName = x.CategoryName
}
Return rs.FirstOrDefault
End Function
End Class
Public Class myCategory
#Region "Primitive Properties"
Public Property CategoryID() As Global.System.Int32
Get
Return _CategoryID
End Get
Set(value As Global.System.Int32)
_CategoryID = value
End Set
End Property
Private _CategoryID As Global.System.Int32
Public Property CategoryName() As Global.System.String
Get
Return _CategoryName
End Get
Set(value As Global.System.String)
_CategoryName = value
End Set
End Property
Private _CategoryName As Global.System.String
#End Region
End Class
Public Class myProduct
#Region "Primitive Properties"
Public Property ProductID() As Global.System.Int32
Get
Return _ProductID
End Get
Set(value As Global.System.Int32)
_ProductID = value
End Set
End Property
Private _ProductID As Global.System.Int32
Public Property ProductName() As Global.System.String
Get
Return _ProductName
End Get
Set(value As Global.System.String)
_ProductName = value
End Set
End Property
Private _ProductName As Global.System.String
Public Property CategoryID() As Nullable(Of Global.System.Int32)
Get
Return _CategoryID
End Get
Set(value As Nullable(Of Global.System.Int32))
_CategoryID = value
End Set
End Property
Private _CategoryID As Nullable(Of Global.System.Int32)
Private _mycategory As myCategory
Public Property myCategory As myCategory
Get
Return _mycategory
End Get
Set(value As myCategory)
_mycategory = value
End Set
End Property
#End Region
End Class
View model
Imports System.Collections.ObjectModel
Imports System.ComponentModel
Public Class MainWindowViewModel
Implements INotifyPropertyChanged
Public Property myProductList As ObservableCollection(Of myProduct)
Public Property myCategoryList As ObservableCollection(Of myCategory)
Private Property _context As myDataRepository
Public Sub New(ByVal db As myDataRepository)
_context = db
myProductList = _context.GetMyProducts()
myCategoryList = _context.GetMyCategories()
End Sub
Private Property _myselectedproduct As myProduct
Public Property mySelectedProduct As myProduct
Get
Return _myselectedproduct
End Get
Set(value As myProduct)
_myselectedproduct = value
mySelectedProduct.myCategory = _context.GetMyCategory(mySelectedProduct.CategoryID)
mySelectedCategory = mySelectedProduct.myCategory
OnPropertyChanged(mySelectedProduct, New System.ComponentModel.PropertyChangedEventArgs("mySelectedProduct"))
End Set
End Property
Private Property _myselectedcategory As myCategory
Public Property mySelectedCategory As myCategory
Get
Return _myselectedcategory
End Get
Set(value As myCategory)
_myselectedcategory = value
OnPropertyChanged(mySelectedCategory, New System.ComponentModel.PropertyChangedEventArgs("mySelectedCategory"))
End Set
End Property
#Region "INotifyPropertyChanged Members"
Private Sub OnPropertyChanged(ByVal sender As Object, ByVal e As PropertyChangedEventArgs)
Dim propertyName As String = e.PropertyName
Me.NotifyPropertyChanged(propertyName)
End Sub
Public Event PropertyChanged(sender As Object, e As System.ComponentModel.PropertyChangedEventArgs) Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged
Private Sub NotifyPropertyChanged(ByVal propertyName As String)
If Me.PropertyChangedEvent IsNot Nothing Then
RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propertyName))
End If
End Sub
#End Region
End Class
|
|
|
|
|
Is the product actually changing in the ViewModel? Set a breakpoint and make sure. If not, you might want to add Mode=TwoWay,UpdateSourceTrigger=PropertyChanged to the SelectedItem bindings.
And on a related note, UpdateSourceTrigger=PropertyChanged is completely irrelevant on a OneWay binding, because the source never gets updated.
Binding modes:
* OneTime = Only changes when the DataContext is changed
* OneWay = This property updates from the source, but changes aren't sent back
* TwoWay = Updates in both directions
Unless you specifically mark the property as BindsTwoWayByDefault , you should assume it's OneWay by default.
|
|
|
|
|
The product is changing. I added the textblocks in the 2nd and 3rd grid rows to show the values of the properties as the combobox selection is made. I also put a break in and "mySelectedCategory" is updated when a choice is made to product.
I made a change to TwoWay and saw no difference.
My understanding of the binding modes matches what you have listed but I thought that UpdateSourceTrigger was still needed to let the viewmodel know that an update was made from the source. With OneWay I do indeed want to say that updates are not sent back, but UpdateSourceTrigger is there to let the view know that updates were made to the model.
|
|
|
|