|
If you copy and paste those exact words into Google you will probably get some useful information.
Use the best guess
|
|
|
|
|
i want to get both samples audio and video using mediastreamsource .
|
|
|
|
|
Hi,
I have a silver light application. When I run it then its URL is like http://localhost/Myfirstapplication.aspx.
I have created another silver light application. Mostly code is copied from first application. But when I run it then its URL is like http://localhost/mysecondapplication.aspx#loginpage.xaml.
Actually I donot want to show .xaml path/name. Can any body tell me what setting should I made to hide .XAML or am I missing somthing ???
|
|
|
|
|
How can I run a store procedure (SQL 2008) from domain services?
default method is to simple
public IQueryable<cars> GetCars()
{
return this.ObjectContext.Cars;
}
It does not have to be a SP, I just thought it may be cleaner, basically what I need to run is something like this:
Select col1 from DBTables where ltrim(rtrim(col1)) not in (select ltrim(rtrim(col2)) from DBTables where col2 is not null)
order by 1
Select col2 from DBTables where ltrim(rtrim(col2)) not in (select ltrim(rtrim(col1)) from DBTables where col1 is not null)
order by 1
any help is greatly appreciated
|
|
|
|
|
|
I'm relatively new to WPF but I've gotten a decent handle on how data binding works except with combo boxes. I have a window in my application that when it loads it shows a list box with all the currently entered users' information. When a item is selected all the information is loaded into text boxes/combo boxes for editing. I got the data binding to work with the text boxes, but I can't get the combo box to bind to the gender property.
I have a class that represents a person. This is a stripped down version with just some of the properties, including the gender property that the combo box needs to bind to:
Public Class Person
Implements IPerson, INotifyPropertyChanged
#Region "Events"
Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged
#End Region
#Region "Variables"
Private _guid As Guid
Private _firstName As String
Private _lastName As String
Private _MiddleName As String
Private _sex As String
Private _created As DateTime
Private _modified As DateTime
#End Region
#Region "Properties"
Public ReadOnly Property GUID As Guid Implements IPerson.GUID
Get
Return _guid
End Get
End Property
Public ReadOnly Property Created As Date Implements IPerson.Created
Get
Return _created
End Get
End Property
Public ReadOnly Property Modified As Date Implements IPerson.Modified
Get
Return _modified
End Get
End Property
Public Property FirstName As String Implements IPerson.FirstName
Get
Return _firstName
End Get
Set(value As String)
_firstName = value
OnPropertyChanged(New PropertyChangedEventArgs("FirstName"))
End Set
End Property
Public Property LastName As String Implements IPerson.LastName
Get
Return _lastName
End Get
Set(value As String)
_lastName = value
OnPropertyChanged(New PropertyChangedEventArgs("LastName"))
End Set
End Property
Public Property MiddleName As String Implements IPerson.MiddleName
Get
Return _MiddleName
End Get
Set(value As String)
_MiddleName = value
OnPropertyChanged(New PropertyChangedEventArgs("MiddleName"))
End Set
End Property
Public Property Sex As String Implements IPerson.Sex
Get
Return _sex
End Get
Set(value As String)
_sex = value
OnPropertyChanged(New PropertyChangedEventArgs("Sex"))
End Set
End Property
#End Region
#Region "Methods"
Public Sub New(guid As Guid, Optional created As DateTime = Nothing, Optional modified As DateTime = Nothing)
Me._guid = guid
Me._created = created
Me._modified = modified
End Sub
Public Sub OnPropertyChanged(ByVal e As PropertyChangedEventArgs)
If Not PropertyChangedEvent Is Nothing Then
RaiseEvent PropertyChanged(Me, e)
End If
End Sub
#End Region
When the window is loaded it calls the following method to pull the information from a MySQL database:
Public Shared Function GetAllEmployees() As ObservableCollection(Of Employee)
Dim connection As New MySqlConnection(connectionString)
Dim command As New MySqlCommand
command.Connection = connection
command.CommandText = StoredProcedures.GetProcedureName(StoredProceduresEnum.GET_ALL_EMPLOYEES)
command.CommandType = CommandType.StoredProcedure
Dim ds As New DataSet
Dim adapter As New MySqlDataAdapter
adapter.SelectCommand = command
adapter.Fill(ds)
Dim employees As New ObservableCollection(Of Employee)
Dim employee As Employee
For Each row As DataRow In ds.Tables(0).Rows
employee = New Employee(New Guid)
With employee
.FirstName = row.Item("FirstName").ToString
.MiddleName = row.Item("MiddleName").ToString
.LastName = row.Item("LastName").ToString
.Sex = row.Item("Sex").ToString
.IDNumber = row.Item("IDNumber").ToString
employees.Add(employee)
End With
Next
Return employees
End Function
*Note that employee inherits from the Person class
When the information is done loading from the database I display it in the list box by using lstEmployees.ItemsSource = employees
My XAML (stripped down) is this:
<ListBox Name="lstEmployees" Grid.Column="0" Grid.RowSpan="2" MinWidth="150" Margin="5,5,5,5" VirtualizingPanel.IsVirtualizing="True" >
<ListBox.ItemTemplate>
<DataTemplate>
<Border Margin="5" BorderThickness="1" BorderBrush="SteelBlue" CornerRadius="4">
<Grid Margin="3">
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<TextBlock FontWeight="Bold">
<TextBlock.Text>
<MultiBinding StringFormat=" {0}, {1} ">
<Binding Path="LastName" />
<Binding Path="FirstName" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>
<TextBlock Grid.Row="1">
<TextBlock.Text>
<MultiBinding StringFormat="ID: {0}">
<Binding Path="IDNumber" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>
</Grid>
</Border>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<Grid x:Name="entryFieldsGrid" Grid.Column="2" Margin="5,5,5,5" Width="Auto" DataContext="{Binding ElementName=lstEmployees, Path=SelectedItem}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" Grid.Row="0" >
<TextBlock Text="First Name:" Padding="0,0,5,0" />
<TextBox x:Name="firstName" Width="150" Text="{Binding Path=FirstName}"/>
<TextBlock Text="Middle Name:" Padding="5,0,5,0"/>
<TextBox x:Name="middleName" Width="150" Text="{Binding Path=MiddleName}"/>
<TextBlock Text="Last Name:" Padding="5,0,5,0"/>
<TextBox x:Name="lastName" Width="150" Text="{Binding Path=LastName}"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Row="1">
<TextBlock Text="Sex:" Padding="0,0,5,0" />
<ComboBox x:Name="cboSex" IsEditable="False" SelectedValue="{Binding Path=Sex}" DisplayMemberPath="Sex" SelectedValuePath="Sex">
</ComboBox>
</StackPanel>
</Grid>
As of now, when I select different employees in the list box, the three name boxes show the appropriate data, however the combo box doesn't show anything. I also had tried adding:
<ComboBoxItem></ComboBoxItem>
<ComboBoxItem>M</ComboBoxItem>
<ComboBoxItem>F</ComboBoxItem>
to the combo box in the hopes that it would select the correct item based on the currently selected employee and that the user would have the ability to change it to one of the supplied values to persists back to the database. However no matter how I change the binding properties, I can not get the combo box to show anything. Whether I have the combo box item elements in the XAML or not, the combo box never shows anything.
What am I doing wrong? Why won't the combo box select the correct gender based upon the currently selected item in the list box?
|
|
|
|
|
DisIsHoody wrote: <ComboBox x:Name="cboSex" IsEditable="False" SelectedValue="{Binding Path=Sex}" DisplayMemberPath="Sex" SelectedValuePath="Sex">
Remove all DisplayMemberPath & SelectedvaluePath. Binding For SelectedValue should be in TwoWay mode.
|
|
|
|
|
Your combo needs an ItemsSource (observable collection of m/f/o) if you use an object then you need the display and value paths otherwise Amitosh is also correct, SelectedValue needs Mode="TwoWay" to store it back to your SelectedItem.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I've a Silverlight application that manages the movement of electronic documents through a series of approval steps. When an approval step is complete I want the application to email the next user in the approval chain that work needs to be accomplished. I cannot depend upon all users logging into the application every day so the email reminders will help those who don't do much in the system.
I can send email from the application with no problems, but again, this is dependent upon the application being opened.
So I'm thinking it is probably best to put a Windows Service or something out on the server that automatically checks the state of the application every 5 minutes or so and handles the email. The point is, I'm open to suggestions.
I think this is something that needs to run off on it's own, separate from the Silverlight UI.
Thoughts, ideas, suggestions?
|
|
|
|
|
I hate workflow application having just delivered 2 of the bloody things!
We used a combination of 2 email sources, instant where the app initiates the default email client (outlook) using the mailto. This is very limited but works for unformatted in your face NOW emails. This also allows the user to tinker with the message.
Scheduled reports from reporting services delivered daily via email. These are nicely formatted and carry a lot more information.
Rather than a windows service I would use a SQL Server job and send the emails from the database.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Before I start the actual question I do know about these articles:
Fill Combobox With Sorted Enum Without Code[^]
Binding and Using Friendly Enums in WPF[^]
Funky WPF - Enumerations and Combo Boxes[^]
Enum to ComboBox binding[^]
However what I want to do is the folloing. Assume a Class that has an Enum as a Property:
Class Test
Public Enum Something As Integer
<Description("Something happended")> Something
<Description("Nothing happended")> Nothing_
End Enum
Private pEnumer As Something = -1
Public Property Enumer() As Something
Get
Return pEnumer
End Get
Set(ByVal value As Something)
pEnumer = value
End Set
End Property
End Class
And now I want to bind a ComboBox to the Property Enumer, and I thought It would be simple to make an own based on the original ComboBox:
Public Class EnumComboBox
Inherits ComboBox
Private _EnumList As New List(Of EnumerationMember)
Private pEnumItemsSorce As [Enum]
Public Property EnumItemsSorce() As [Enum]
Get
Return pEnumItemsSorce
End Get
Set(ByVal value As [Enum])
pEnumItemsSorce = value
Me.ItemsSource = [Enum].GetValues(value.GetType)
End Set
End Property
Public Function GetEnumItemSource(obj As DependencyObject) As [Enum]
Return EnumItemsSorce
End Function
Public Sub SetEnumItemSource(obj As DependencyObject, value As [Enum])
EnumItemsSorce = value
End Sub
Public Shared ReadOnly EnumItemSourceProperty As DependencyProperty = DependencyProperty.RegisterAttached("EnumItemSource", GetType([Enum]), GetType(EnumComboBox), New PropertyMetadata(Nothing, AddressOf OnEnumItemSourceChanged))
Private Shared Sub OnEnumItemSourceChanged(sender As DependencyObject, e As DependencyPropertyChangedEventArgs)
Dim control = TryCast(sender, ItemsControl)
If control IsNot Nothing Then
If e.NewValue IsNot Nothing Then
Dim _enum = [Enum].GetValues(TryCast(e.NewValue, Type))
control.ItemsSource = _enum
End If
End If
End Sub
Protected Overrides Sub OnItemContainerStyleSelectorChanged(oldItemContainerStyleSelector As System.Windows.Controls.StyleSelector, newItemContainerStyleSelector As System.Windows.Controls.StyleSelector)
MyBase.OnItemContainerStyleSelectorChanged(oldItemContainerStyleSelector, newItemContainerStyleSelector)
End Sub
Protected Overrides Sub OnSelectionChanged(e As System.Windows.Controls.SelectionChangedEventArgs)
MyBase.OnSelectionChanged(e)
End Sub
Private _enumType As Type
Private Sub GetValues(ByVal E As [Enum])
Dim result As New List(Of String)
Dim _enumType As Type
_enumType = E.GetType
Dim enumValues = [Enum].GetValues(_enumType)
Dim f = (From enumValue In enumValues Select New EnumerationMember() With { _
.Value = enumValue, _
.Description = enumValue.GetDescription(enumValue) _
}).ToList
_EnumList = f
End Sub
Private Function GetDescription(enumValue As Object) As String
Dim descriptionAttribute = TryCast(_enumType.GetField(enumValue.ToString()).GetCustomAttributes(GetType(ComponentModel.DescriptionAttribute), False).FirstOrDefault(), ComponentModel.DescriptionAttribute)
Return If(descriptionAttribute IsNot Nothing, descriptionAttribute.Description, enumValue.ToString())
End Function
Public Class EnumerationMember
Public Property Description() As String
Get
Return m_Description
End Get
Set(value As String)
m_Description = value
End Set
End Property
Private m_Description As String
Public Property Value() As Object
Get
Return m_Value
End Get
Set(value As Object)
m_Value = value
End Set
End Property
Private m_Value As Object
End Class
End Class
The Idea is to bind the Enum property "Something" dire3ctly to the combobox, mewaning when I change the combobox index the property in the Test class also changes.
Question is: How can I alter the code above to make this happen?
|
|
|
|
|
Kenneth Haugland wrote: mewaning when I change the combobox index the property in the Test class also changes
Ignoring the detail of the rest of your question, I nearly went cross eyed reading VB as it has been so long, this seems to indicate the issue is in your combo binding. Are yo binding your combo to the datacontext in xaml where you should be setting either the SelectedItem or the SelectedValue and the Mode to TwoWay to drive the change in the ViewModel.
Or am I missing something?
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Yes I can do that, but that would soon get messy, and I dont really like it (but it works). So I thought I could make a control that could do all of that without any XAML, just by creating a new Control that inherits the ComboBox.
|
|
|
|
|
Kenneth Haugland wrote: without any XAML
Wat, are you nuts, one of the main benefits of SL/WPF is the xaml binding of the data. I've heard of roll your own (I'm a great believer in it) but that is taking it way too far.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Ehhmm... I meant without cluttering up the XAML, not without it
|
|
|
|
|
Ahh good, you were about to be consigned to the nether regions of...
Even so using the SelectedValue/SelectedItem are part of the core binding strategy. Binding to an ENUM on the other hand must have been a challenge and it looks like it "cluttered" up your code somewhat! So is the selection changing your core issue here.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Yes actually, sort of, the values in the combobox stems from the Description of the Enum's and not the enum itself. I actually want to know how do you tell the property in the class, that the selection in hte combobox has change, so you should now update the property.
|
|
|
|
|
I got it working but I had to do thius:
Private Sub cmbEnumComboBox_SelectionChanged(sender As System.Object, e As System.Windows.Controls.SelectionChangedEventArgs) Handles cmbEnumComboBox.SelectionChanged
t.Enumer = cmbEnumComboBox.EnumItemsSorce
End Sub
Now I know that is stupid, how could I do this without this, any ideas?
|
|
|
|
|
I found a solution, so now I can bind an Enum property to a custom combobox without any clutter in Code behind or XAML:
Imports System.ComponentModel
Namespace WPF
Public Class COmboBoxAttached
Inherits ComboBox
Private _EnumList As New List(Of EnumerationMember)
Private DontRebind As Boolean = False
Private pEnumItemsSorce As [Enum]
Public Property EnumItemsSorce() As [Enum]
Get
Return pEnumItemsSorce
End Get
Set(value As [Enum])
If Not DontRebind Then
GetValues(value)
Me.ItemsSource = _EnumList
Me.DisplayMemberPath = "Description"
Me.SelectedValue = "Value"
End If
DontRebind = False
pEnumItemsSorce = value
End Set
End Property
Protected Overrides Sub OnSelectionChanged(e As System.Windows.Controls.SelectionChangedEventArgs)
If Me.SelectedValue IsNot Nothing Then
DontRebind = True
EnumItemsSorce = DirectCast(Me.SelectedValue, EnumerationMember).Value
End If
MyBase.OnSelectionChanged(e)
End Sub
Private _enumType As Type
Private Sub GetValues(ByVal E As [Enum])
Dim result As New List(Of String)
Dim _enumType As Type
_enumType = E.GetType
Dim enumValues = [Enum].GetValues(_enumType)
Dim f = (From enumValue In enumValues Select New EnumerationMember() With { _
.Value = enumValue, _
.Description = DirectCast(enumValue, [Enum]).GetDescription _
}).ToList
_EnumList = f
End Sub
Private Function GetDescription(enumValue As Object) As String
Dim descriptionAttribute = TryCast(_enumType.GetField(enumValue.ToString()).GetCustomAttributes(GetType(ComponentModel.DescriptionAttribute), False).FirstOrDefault(), ComponentModel.DescriptionAttribute)
Return If(descriptionAttribute IsNot Nothing, descriptionAttribute.Description, enumValue.ToString())
End Function
Public Class EnumerationMember
Public Property Description() As String
Get
Return m_Description
End Get
Set(value As String)
m_Description = value
End Set
End Property
Private m_Description As String
Public Property Value() As Object
Get
Return m_Value
End Get
Set(value As Object)
m_Value = value
End Set
End Property
Private m_Value As Object
End Class
End Class
End Namespace
|
|
|
|
|
Hello,
I have a Window and a viewModel class as a data context of the window.
When i try to change some variables in the viewModel class that are binded to Window properties.
I get the next exception:
"Cannot use a DependencyObject that belongs to a different thread than its parent Freezable".
I know that in WPF you dont have access to a UI elements properties from other threads but here i dont directly access the UI element properties i access some variables that are binded to them.
how can i solve this?
|
|
|
|
|
Make sure you are accessing the UI / properties on the right thread.
|
|
|
|
|
Hi Everybody,
Good Day.
Am gonna develop an windows based application in WPF like holding employee profile. It will save the data and also it will have employee image and his/hers parents image. i am using backedn server as SQL and the SQL server is centralized and i will be accessing through internet.
Now i want suggestion that where should i save my images? is it ok to save in image data type of DB server?
or do i need to use any common folder file systems? if as this is an windows application do i need to give any persmissions? so that it will be accessible from windows app?
or is it possible to use google picasa or anything like that? and will it have any licencing issue if i market the application?
please suggest me the best way to save the images from windows application?
thanks in advance.
|
|
|
|
|
If you are using Silverlight, you will not be able to access the file system folder without elevated permissions.
Thus it will be easier for you to store images on the DB server using a web service.
|
|
|
|
|
Dear Abinav,
Thanks for your reply
When you say to store images in database and use web service?
will image will transfer fast in web service? and how to send image via webservice?
or will it work through ADO.NET via internet?
which will be faster?
thanks in advance/
|
|
|
|
|
Store everything in the DB. Do you really want a file share open to the internet?
|
|
|
|