 |
 |
Apologies for the shouting but this is important.
When answering a question please:
- Read the question carefully
- Understand that English isn't everyone's first language so be lenient of bad spelling and grammar
- If a question is poorly phrased then either ask for clarification, ignore it, or mark it down. Insults are not welcome
- If the question is inappropriate then click the 'vote to remove message' button
Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
 |
For those new to message boards please try to follow a few simple rules when posting your question.- Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
- Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
- Keep the subject line brief, but descriptive. eg "File Serialization problem"
- Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
- Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
- Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
- If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode "<" (and other HTML) characters when pasting" checkbox before pasting anything inside the PRE block, and make sure "Use HTML in this post" check box is checked.
- Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
- Please do not post links to your question into an unrelated forum such as the lounge. It will be deleted. Likewise, do not post the same question in more than one forum.
- Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
- If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
- No advertising or soliciting.
- We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
 |
Hi All,
I have created the Virtual Directory on the Server and copied all .exe, xbap and manifest files, when trying to access the xbap application, I'm getting the following error. Please help me what steps am I missing in deploying the application.
Here is the Error log message
PLATFORM VERSION INFO
Windows : 6.1.7601.65536 (Win32NT)
Common Language Runtime : 4.0.30319.42000
System.Deployment.dll : 4.6.118.0 built by: NETFXREL3STAGE
clr.dll : 4.6.1076.0 built by: NETFXREL3STAGE
dfdll.dll : 4.6.118.0 built by: NETFXREL3STAGE
dfshim.dll : 4.0.41209.0 (Main.041209-0000)
SOURCES
Deployment url : <a href="http://localhost/WPFBrowserApplication/WpfBrowserApplication12015.xbap">http: Application url : <a href="http://localhost/WPFBrowserApplication/WpfBrowserApplication12015.exe.manifest">http:
IDENTITIES
Deployment Identity : WpfBrowserApplication12015.xbap, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c836e075e9e59aa1, processorArchitecture=msil
Application Identity : WpfBrowserApplication12015.exe, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c836e075e9e59aa1, processorArchitecture=msil, type=win32
APPLICATION SUMMARY
* Online only application.
* Browser-hosted application.
ERROR SUMMARY
Below is a summary of the errors, details of these errors are listed later in the log.
* An exception occurred while downloading the application. Following failure messages were detected:
+ Downloading <a href="http://localhost/WPFBrowserApplication/WpfBrowserApplication12015.exe.deploy">http: + The remote server returned an error: (404) Not Found.
COMPONENT STORE TRANSACTION FAILURE SUMMARY
No transaction error was detected.
WARNINGS
There were no warnings during this operation.
OPERATION PROGRESS STATUS
No phase information is available.
ERROR DETAILS
Following errors were detected during this operation.
* [9/18/2016 8:02:15 PM] System.Deployment.Application.DeploymentDownloadException (Unknown subtype)
- Downloading <a href="http://localhost/WPFBrowserApplication/WpfBrowserApplication12015.exe.deploy">http: - Source: System.Deployment
- Stack trace:
at System.Deployment.Application.SystemNetDownloader.DownloadSingleFile(DownloadQueueItem next)
at System.Deployment.Application.SystemNetDownloader.DownloadAllFiles()
at System.Deployment.Application.FileDownloader.Download(SubscriptionState subState)
at System.Deployment.Application.DownloadManager.DownloadDependencies(SubscriptionState subState, AssemblyManifest deployManifest, AssemblyManifest appManifest, Uri sourceUriBase, String targetDirectory, String group, IDownloadNotification notification, DownloadOptions options)
at System.Deployment.Application.DeploymentManager.SynchronizeCore(Boolean blocking)
at System.Deployment.Application.DeploymentManager.SynchronizeAsyncWorker()
- Inner Exception -
System.Net.WebException
- The remote server returned an error: (404) Not Found.
- Source: System
- Stack trace:
at System.Net.HttpWebRequest.GetResponse()
at System.Deployment.Application.SystemNetDownloader.DownloadSingleFile(DownloadQueueItem next)
COMPONENT STORE TRANSACTION DETAILS
No transaction information is available.
I am searching and asking with friends and colleagues, any type of help is appreciated maybe a code snippet, a link or even a suggestions help. Thanks in advance.
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
 |
indian143 wrote: The remote server returned an error: (404) Not Found.
Either your files do not exist on your server, or you haven't configured the MIME type for them.
MIME Types for ClickOnce deployment | RobinDotNet's Blog[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
 |
I tried but I don't know how to install mime types on a Virtual Directory or Web Application, I found some vbs code I saved and ran it to install Mime types, it gave me error.
So far I couldn't find how to install MIME types, can you please help me with that?
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
 |
Did you read the blog post I linked to? It has links to Microsoft's instructions for setting up MIME types in IIS.
Instructions for setting up MIME types in IIS6:
Configure MIME Types (IIS 6.0)[^]
Instructions for setting up MIME types in IIS7 (or later):
Configuring MIME Types in IIS 7[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
 |
Hi,
I installed all those Mime types on my Server, still I am getting the same error, can you please give me some suggestion about it?
I have copied .exe file, .manifest file and .xbap file from bin directory of the application into Virtual Directory, am I missing anything here? Do I need to have .deploy file etc?
I followed all the steps that are provided here : GADS Open Source[^]
If I'm missing something please let me know, any help is greatly appreciated. Thanks my friend .
Still I am getting the following Error:
PLATFORM VERSION INFO
Windows : 6.1.7601.65536 (Win32NT)
Common Language Runtime : 4.0.30319.42000
System.Deployment.dll : 4.6.1055.0 built by: NETFXREL2
clr.dll : 4.6.1076.0 built by: NETFXREL3STAGE
dfdll.dll : 4.6.1055.0 built by: NETFXREL2
dfshim.dll : 4.0.41209.0 (Main.041209-0000)
SOURCES
Deployment url : http://localhost/WpfBrowserApplication12015/WpfBrowserApplication12015.xbap
Application url : http://localhost/WpfBrowserApplication12015/WpfBrowserApplication12015.exe.manifest
IDENTITIES
Deployment Identity : WpfBrowserApplication12015.xbap, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c836e075e9e59aa1, processorArchitecture=msil
Application Identity : WpfBrowserApplication12015.exe, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c836e075e9e59aa1, processorArchitecture=msil, type=win32
APPLICATION SUMMARY
* Online only application.
* Browser-hosted application.
ERROR SUMMARY
Below is a summary of the errors, details of these errors are listed later in the log.
* An exception occurred while downloading the application. Following failure messages were detected:
+ Downloading http://localhost/WpfBrowserApplication12015/WpfBrowserApplication12015.exe.deploy did not succeed.
+ The remote server returned an error: (404) Not Found.
COMPONENT STORE TRANSACTION FAILURE SUMMARY
No transaction error was detected.
WARNINGS
There were no warnings during this operation.
OPERATION PROGRESS STATUS
No phase information is available.
ERROR DETAILS
Following errors were detected during this operation.
* [9/20/2016 2:25:44 PM] System.Deployment.Application.DeploymentDownloadException (Unknown subtype)
- Downloading http://localhost/WpfBrowserApplication12015/WpfBrowserApplication12015.exe.deploy did not succeed.
- Source: System.Deployment
- Stack trace:
at System.Deployment.Application.SystemNetDownloader.DownloadSingleFile(DownloadQueueItem next)
at System.Deployment.Application.SystemNetDownloader.DownloadAllFiles()
at System.Deployment.Application.FileDownloader.Download(SubscriptionState subState)
at System.Deployment.Application.DownloadManager.DownloadDependencies(SubscriptionState subState, AssemblyManifest deployManifest, AssemblyManifest appManifest, Uri sourceUriBase, String targetDirectory, String group, IDownloadNotification notification, DownloadOptions options)
at System.Deployment.Application.DeploymentManager.SynchronizeCore(Boolean blocking)
at System.Deployment.Application.DeploymentManager.SynchronizeAsyncWorker()
- Inner Exception -
System.Net.WebException
- The remote server returned an error: (404) Not Found.
- Source: System
- Stack trace:
at System.Net.HttpWebRequest.GetResponse()
at System.Deployment.Application.SystemNetDownloader.DownloadSingleFile(DownloadQueueItem next)
COMPONENT STORE TRANSACTION DETAILS
No transaction information is available
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
modified 20-Sep-16 17:32pm.
|
|
|
|
 |
indian143 wrote: Downloading http://localhost/WpfBrowserApplication12015/WpfBrowserApplication12015.exe.deploy did not succeed.
- The remote server returned an error: (404) Not Found.
Either the .deploy file does not exist in that path on your server, or you didn't configure the MIME type for .deploy files.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
 |
I configured .deploy mime type on the IIS Rick not able figure it out my friend, still checking, Silverlight Application is working on the same IIS, only WPF browser app is not working.
Do I need to set up anything in the App Config file any properties etc.? Do I need to put some Certificate related information on the Config file? I am not sure - I have been searching my friend. That one little thing can keep my Work going - thanks for coming up to help me my friend.
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
 |
If you request http://localhost/WpfBrowserApplication12015/WpfBrowserApplication12015.exe.deploy in your web browser, do you get the file, or do you get an error?
If you get an error, try using failed request tracing[^] to diagnose the problem.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
 |
Yes when I type this in the browser ()[^] I am getting file not found error (404).
I don't know what it means and how to resolve it my friend, sincerely and seriously
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
 |
So try the failed request tracing, as I suggested.
Either the file doesn't exist, or something isn't configured properly in IIS. Failed request tracing will tell you what the problem is.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
 |
I have enabled the IIS request failed tracing I got the following xml file, can you please help me in finding out what I am missing when I try to make request for the .deploy as mentioned in the above message you sent me. I tried to put the message here but the thing is here its not taking the HTML message of that long. But anyways I am not able to understand why is it failing.
Can you please help in that aspect a little bit?
="1.0" ="UTF-8"
='text/xsl' ='freb.xsl'
<!-- saved from url=(0014)about:internet -->
<failedRequest url="http://localhost:80/WpfBrowserApplication12015/WpfBrowserApplication12015.exe.deploy"
siteId="1"
appPoolId="WPF Browser App Pool"
processId="9100"
verb="GET"
remoteUserName=""
userName=""
tokenUserName="NT AUTHORITY\IUSR"
authenticationType="anonymous"
activityId="{00000000-0000-0000-0600-0080020000FF}"
failureReason="STATUS_CODE"
statusCode="404"
triggerStatusCode="404"
timeTaken="62"
xmlns:freb="http://schemas.microsoft.com/win/2006/06/iis/freb"
>
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
<Provider Name="WWW Server" Guid="{3A2A4E84-4C21-4981-AE10-3FDA0D9B0F83}"/>
<EventID>0</EventID>
<TimeCreated SystemTime="2016-09-21T17:55:47.580Z"/>
<Correlation ActivityID="{00000000-0000-0000-0600-0080020000FF}"/>
<Execution ProcessID="9100" ThreadID="15072"/>
<Computer>BSCWL751990</Computer>
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
 |
Not without seeing the full file.
If you open the XML file in Internet Explorer, you should see a detailed log of the failed request, and the breakdown of what caused the error.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
 |
Hi,
xml file is too big, can you please give me some hints where to look or some searching criteria mostly its saying 400 error and not saying which file is missing my friend. I know its kind of bugging for you.
If you can help me its really great - thank you.
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
 |
If you open the XML file in Internet Explorer, you will get a formatted list of errors and warnings.
If you can't work out what they mean, then post the file to a new GitHub Gist[^] and provide the link.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
 |
I have a situation where I am trying to change the visibility of StackPanels in a child UserControl from a button in the parent window. I created a custom class below that holds a static reference to the UserControl value and in the UserControl View constructor the user control value is assigned to the static EditWindow class uc static value. Now what I am trying to do is hide and show StackPanels in the child UserControl view the button in the parent window is clicked. When the button is clicked the StackPanels are not changing from Collapsed to Visible. All of the code is below:
EditWindow.cs
public static class EditWindow
{
public static string buttonString;
public static Button button;
public static View.ApplicationInfoView uc;
}
<v:ApplicationInfoView />
ApplicationInfoView StackPanels
<StackPanel Name="Sp1">
<StackPanel Name="Sp2">
<StackPanel Name="Sp2">
EditWindow.uc = this;
private void btnEdit_Click(object sender, RoutedEventArgs)
{
EditWindow.uc.editAppInfo();
}
editAppInfo()
{
EditWindow.uc.sp1.Visibility = Visibility.Collapsed;
EditWindow.uc.sp2.Visibility = Visibility.Visible;
EditWindow.uc.sp3.Visibility = Visibility.Visibile;
}
|
|
|
|
 |
If the StackPanels are "empty", toggling visibility will make no difference unless you use an explicit minimum height, width and / or color in order to "see" them.
Also, the layout (right or wrong) impacts what one sees (in-back versus in-front; etc); regardless of what the "code-behind" is doing.
|
|
|
|
 |
 I have now tried changing the way I am performing my task. Now in my child user control constructor I am loading the UserControl as follows:
// Remember EditWindow is a static class and uc is a static // public value of View.ApplicationInfoView which is the // UserControl that is a View with a base class of // UserControl.
EditWindow.uc = this;
And now calling the method the following on the parent window button click event:
// Remember the StackPanel spGrid is Collapsed onload
private void btn_click(object sender, RoutingEventArgs e)
{
EditWindow.uc.spGrid.Visibility = Visibility.Visible;
}
Now Here is my StackPanel on the child UserControl:
<StackPanel Name="spGrid" Grid.Column="0" Grid.ColumnSpan="4" Grid.Row="2">
<Grid Name="Grid2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="425" />
<ColumnDefinition Width="425" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="25" />
<RowDefinition Height="75" />
<RowDefinition Height="75" />
<RowDefinition Height="75" />
<RowDefinition Height="75" />
<RowDefinition Height="75" />
<RowDefinition Height="75" />
<RowDefinition Height="75" />
</Grid.RowDefinitions>
<Label Height="36" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" FontSize="16" Background="#FF004A78" Content="Identifying Documents" FontWeight="Bold" Foreground="White" Margin="0,0,0,0"/>
<StackPanel Grid.Row="1" Grid.Column="0" >
<Border BorderBrush="White" BorderThickness="3">
<Border BorderBrush="Gray" BorderThickness="1">
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<StackPanel Width="420" x:Name="_Passport" Margin="0,0,0,0" Height="65">
<StackPanel Orientation="Horizontal">
<TextBlock Height="45" Width="Auto" FontWeight="Bold" Foreground="#FF004A78" FontSize="18" x:Name="Passport_TextBlock" Text="Passport" TextAlignment="Left"/>
<Image Source="/Images/Attachments_button.jpg" Margin="180, 0, 0 ,0" MouseLeftButtonUp="Click_MouseLeftButtonUp" Name="PPTop" Width="Auto" Height="45" />
<Image Source="/Images/Attachments_button.jpg" Margin="50, 0, 0 ,0" Name="PPBottom" Width="Auto" Height="45" />
</StackPanel>
<TextBlock Height="20" Width="Auto" Foreground="#FF004A78" FontSize="12" TextWrapping="WrapWithOverflow" x:Name="Passport2_TextBlock" Text="(Color copy, top and bottom) Perferred Passport Top Passport Bottom" TextAlignment="Left"/>
</StackPanel>
</StackPanel>
</StackPanel>
</Border>
</Border>
</StackPanel>
</StackPanel>
</Grid>
</StackPanel>
Now, again the StackPanel I am trying to hide/show is Name="spGrid". It houses my Grid "Grid2". Now this StackPanel is housed in it's own Grid. Shown is the nested Grid. Also, I am only showing you only one of the rows in the nested Grid of StackPanel spGrid. The other rows have the same type of controls. Again I don't know why when my EditWindow static class's UserControl uc set's it's StackPanel spGrid to visible it stil stays hidden.
|
|
|
|
 |
This is one of those situations where the XAML should be "re-considered". (The "depth" of this simple visual tree is sure ... "deep"...)
Even your top "stack panel" is imbedded in a Grid; so you've still not got the whole picture.
State what you're trying to do from a "user" / functional point-of-view, and you'll probably get some good design answers to get you off with a less "complicated" (XAML) design / approach.
|
|
|
|
 |
Hi All,
I am using a Silverlight listbox on which I display some integers, when I select a particular item of listbox (ie integer), it has to show me the value of that integer. Showing part is working perfect but the problem is when I select one item and then go to another item, silverligh is not clearing the selection of the first one instead keeping the selection on both, which looks weird to customer, any help is appreciated.
Here is my xaml
<UserControl x:Class="RollDiceApp.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"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300"
xmlns:local="clr-namespace:RollDiceApp"
xmlns:viewmodel="clr-namespace:RollDiceApp.ViewModel"
Height="650" Width="700"
Name="diceGamePage"
>
<UserControl.DataContext>
<viewmodel:DiceGameViewModel x:Name="_diceGameViewModel"
/>
</UserControl.DataContext>
<pre>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition>
</ColumnDefinition>
<ColumnDefinition Width="76.988"></ColumnDefinition>
</Grid.ColumnDefinitions>
<ListBox x:Name="lblHistory" Margin="1.988,40.96,10,10" Grid.Column="1" FontSize="21.333"
FontWeight="Bold" FontStyle="Italic"
ItemsSource="{Binding Items}"
SelectedItem="{Binding Path=SelectedItem, Mode=TwoWay}" SelectionMode="Single" >
</ListBox>
<Button x:Name="cmdRollDice" Content="Roll Dice" VerticalAlignment="Top" Margin="12,13,0,0" HorizontalAlignment="Left" Width="65"
Command="{Binding Path=ClickSaveCommand}" >
</Button>
<Button x:Name="cmdClearAllDice" Content="Clear All Dice" VerticalAlignment="Top" Margin="610,13,-2,0" HorizontalAlignment="Left" Width="92"
Command="{Binding Path=ClearHistoryCommand}" Grid.ColumnSpan="2" >
</Button>
<Image x:Name="imgDice" Margin="10, 42.97,10,10" Source="{Binding ImageSourcePath}" />
</Grid>
Here is my ViewModel
namespace RollDiceApp.ViewModel
{
public class DiceGameViewModel : INotifyPropertyChanged, IDataErrorInfo
{
public DiceGameViewModel()
{
_items = new ObservableCollection<int>();
_imageSourcePath = string.Empty; }
private string GetNewImagePath(int v)
{
if ((v == null) || (v <= 0))
v = 1;
return HelperMethods.GetRootDirectory() + @"/Images/" + v.ToString() + ".jpg";
}
private int GetRandom(int min, int max)
{
Random generator = new Random();
return generator.Next(min, max);
}
private string _imageSourcePath;
public string ImageSourcePath {
get { return _imageSourcePath; }
set
{
_imageSourcePath = value;
NotifyPropertyChanged("ImageSourcePath");
}
}
private ObservableCollection<int> _items;
public ObservableCollection <int> Items
{
get { return _items; }
set
{
_items = value;
NotifyPropertyChanged("Items");
}
}
private int _selecteditem;
public int SelectedItem {
get { return _selecteditem; }
set
{
_selecteditem = value;
NotifyPropertyChanged("SelectedItem");
DisplayNewDiceValue(value);
}
}
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged(string propertyName)
{
PropertyChangedEventHandler handler = PropertyChanged;
if(null!=handler)
{
handler(this, new PropertyChangedEventArgs(propertyName));
}
}
private void DisplayNewDiceValue(int val)
{
ImageSourcePath = GetNewImagePath(val);
NotifyPropertyChanged("ImageSourcePath");
}
private void DisplayHistory(int val)
{
_items.Add(val);
NotifyPropertyChanged("ImageSourcePath");
}
private void ClickRollDice()
{
int i = GetRandom(1, 6);
DisplayNewDiceValue(i);
DisplayHistory(i);
}
private void CmdClearHistory()
{
_items.Clear();
ImageSourcePath = "";
NotifyPropertyChanged("ImageSourcePath");
}
private ICommand _clickSaveCommand;
public ICommand ClickSaveCommand {
get { return _clickSaveCommand ??
(_clickSaveCommand = new RollDiceApp.ViewModel.Command.RollDiceCommand(() => ClickRollDice(), true));
} }
private ICommand _clearHistoryCommand;
public ICommand ClearHistoryCommand
{
get
{
return _clickSaveCommand ??
(_clickSaveCommand = new RollDiceApp.ViewModel.Command.RollDiceCommand(() => CmdClearHistory(), true));
}
}
string IDataErrorInfo.this[string columnName]
{
get
{
throw new NotImplementedException();
}
}
string IDataErrorInfo.Error
{
get
{
throw new NotImplementedException();
}
}
}
}
Here is my Command
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
namespace RollDiceApp.ViewModel.Command
{
public class RollDiceCommand : ICommand
{
private Action _action;
private Boolean _canExecute;
public RollDiceCommand(Action _action, Boolean _canExecute)
{
this._action = _action;
this._canExecute = _canExecute;
}
bool ICommand.CanExecute(object parameter)
{
return _canExecute;
}
public event EventHandler CanExecuteChanged;
void ICommand.Execute(object parameter)
{
_action();
}
}
}
Here is my other class
namespace RollDiceApp
{
public class HelperMethods
{
public static string GetRootDirectory()
{
string uriPath = Application.Current.Host.Source.ToString();
Uri uri = new Uri(uriPath);
Uri parent = new Uri(uri, "..");
return parent.ToString();
}
}
}
Here is my App.xaml
<Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="RollDiceApp.App"
<pre>
>
There are 6 images in images folder with names 1.jpg to 6.jpg, you can create any Images for that.
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
 |
Hi All,
I have created xbap application and moved the xbap, exe and manifest files into wwroot folder.
Now to be able to use/call this xbap file from clients browser, I have few questions
- do I need to create a html file to call this xbap from browser? If I need to, can you please give me the sample tags how to call?
- I tried to call xbap it looked like it was executing but did not, it seems like certificates or permissions are the issue, if I want to give certificate or permissions, how can I do it on the Virtual directory? I am using IIS 7
- Do I need to install MIME types on IIS to exec my xbap file? Reason is I got a script from msdn which installs it but it was giving me error, if I need to have them installed, is there any better and guaranteed approach to do the same on IIS 7.
I am searching and inquiring with friends and colleagues but anything helps a small code snippet, a link or even a suggestion helps.
Thanks in advance my friends.
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
 |
Hello,
i'm working with expanders in MVVM and i trying to get notification in the viewmodel when the expander is already opened and when it's opened i want to make print screen to the expander content.
and the scenario is like this:
1)i open the expander that binded to IsExpanderOpen property in the VM and fill the details i want
2)i close the expander (don't ask why it's only example)
3)press OK to save the details of expander controls in DB
4)the OK i pressed call to realycommand 'OpenExpander()' that execute the line IsExpanderOpen=true
5)then i make print screen to the content of opened expander(but it captures closed expander)
this scenario doesn't work because the viewmodel doesn't know to wait the xaml to be rendered when the expander is opended.
i don't want code behind so is there any way to know when the ui is already render the operation
and only then to trigger the viewmodel?
|
|
|
|
 |
I haven't tested this but I would imagine it would be as simple as binding an to the Expanded event (can be done with an EventToCommand). However, if it takes the inner content a while to load up; e.g. because you are lazy loading, then you need to transfer the print logic to wait for that instead.
This space for rent
|
|
|
|
 |
Ok look this is the code of xaml i use event with command and also send the expander as parameter
|
|
|
|
 |
Okay, then you are going to have to get to the ContentRendered event (not easily done I'm afraid). To do this, if I were you, I would create a behavior that behaved something like this internally:AssociatedObject.Loaded += LoadedEvent;
private void LoadedEvent(object sender, RoutedEventArgs e)
{
PresentationSource presentationSource = PresentationSource.FromVisual((Visual)sender);
presentationSource.ContentRendered += ContentRenderedHandler;
}
private void ContentRenderedHandler(object sender, EventArgs e)
{
((PresentationSource)sender).ContentRendered -= ContentRenderedHandler;
}
This space for rent
|
|
|
|
 |
OK i will try your solution
thank you.
|
|
|
|
 |
correction: This is the xaml code
<Expander x:Name="AExpander" Margin="0,0,0,5" IsExpanded="{Binding SectionAExpander}"
IsEnabled="{Binding WasAppNumEntered}" Style="{StaticResource LsExpander}">
<behaviors:CommandBehaviorCollection.Behaviors>
<behaviors:BehaviorBinding Event="Expanded" Command="{Binding OnExpandedCommand}" CommandParameter="{Binding ElementName=AExpander}"/>
</behaviors:CommandBehaviorCollection.Behaviors>
<Expander.Header>
|
|
|
|
 |
and by the way you said to transfer the logic to wait
do you suggest to use another thread except the ui thread?
|
|
|
|
 |
Hi,
I have to create some ContentControl code behind and be able to change their content and their DataTemplate according to their data type (image or text)
(So, I've created a ContentControl code behind, given it (code-behind too) a style from the XAML. In this style I've set DataTemplates)
I'm blocked with a binding problem! The 'person' object is displaying but I can't get to its 'display_text' property!
Could you please help? Thanks!!
PS: By the way, my goal is to create containers dynamically, then send them a 'person' object and have a picture displayed if available or a text displayed (if image not available)...so, if you have other suggestions on how to achieve this they all are welcome!!
<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2...l/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WpfApplication1"
Title="MainWindow" Height="350" Width="525" Background="#FF3A3A48">
<Window.Resources>
<local:RelativeToAbsolutePathConverter x:Key="relToAbsPathConverter" />
<DataTemplate x:Key="ccTexte">
<TextBlock Text="{Binding display_text}" HorizontalAlignment="Center" Foreground="Beige"/>
<!--<TextBlock Text="{Binding Path=display_text}" HorizontalAlignment="Center" Foreground="Beige"/>-->
<!--<TextBlock DataContext="{Binding DataContext,RelativeSource={RelativeSource AncestorType={x:Type ContentControl}}}" Text="{Binding Path=display_text}" HorizontalAlignment="Center" Foreground="Beige"/>-->
</DataTemplate>
<DataTemplate x:Key="ccImage">
<Image x:Name="img" Source="{Binding display_image, Converter={StaticResource relToAbsPathConverter}}"/>
</DataTemplate>
<Style x:Name="ccStyle" TargetType="ContentControl">
<Setter Property="ContentTemplate" Value="{StaticResource ccTexte}"/>
<!--<Setter Property="ContentTemplate" Value="{StaticResource ccImage}"/>
<Style.Triggers>
<DataTrigger Binding="{Binding Source={StaticResource display_image}}" Value="{x:Null}">
<Setter Property="ContentTemplate" Value="{StaticResource ccTexte}"/>
</DataTrigger>
</Style.Triggers>-->
</Style>
</Window.Resources>
<Grid Name="mainGrid">
<Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="416,12,0,0" Name="Button1" VerticalAlignment="Top" Width="75" />
</Grid>
</Window>
Imports System.IO
Class MainWindow
Private Sub MainWindow_Loaded(sender As Object, e As System.Windows.RoutedEventArgs) Handles Me.Loaded
mainGrid.Children.Add(designCC(300, 200, "01"))
Dim cc As ContentControl = LogicalTreeHelper.FindLogicalNode(mainGrid, "CC_01")
cc.Content = New person With {.display_image = "01.png", .display_text = "Text 01"}
End Sub
Private Sub Button1_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles Button1.Click
Dim cc As ContentControl = LogicalTreeHelper.FindLogicalNode(mainGrid, "CC_01")
cc.Content = New person With {.display_image = "02.png", .display_text = "Text 02"}
End Sub
Private Function designCC(width As Integer, height As Integer, id As String) As ContentControl
Dim cc As New ContentControl
cc.Width = width
cc.Height = height
cc.Name = "CC_" & id
cc.Style = DirectCast(Me.Resources("ccStyle"), Style)
Return cc
End Function
End Class
Public Class person
Private _display_image As String
Public Property display_image() As String
Get
Return _display_image
End Get
Set(value As String)
_display_image = value
End Set
End Property
Private _display_text As String
Public Property display_text() As String
Get
Return _display_text
End Get
Set(value As String)
_display_text = value
End Set
End Property
End Class
Public Class RelativeToAbsolutePathConverter
Implements IValueConverter
Public Function Convert(ByVal value As Object, ByVal targetType As Type, ByVal parameter As Object, ByVal culture As System.Globalization.CultureInfo) As Object Implements IValueConverter.Convert
Dim relative As [String] = TryCast(value, String)
If relative Is Nothing Or relative = "" Then
Return Nothing
End If
Return System.AppDomain.CurrentDomain.BaseDirectory & "Images\" & relative
End Function
Public Function ConvertBack(ByVal value As Object, ByVal targetType As Type, ByVal parameter As Object, ByVal culture As System.Globalization.CultureInfo) As Object Implements IValueConverter.ConvertBack
Throw New NotImplementedException()
End Function
End Class
|
|
|
|
 |
I am currently using the SelectionChanged event in my ListView to fire when a row in the GridView is selected. Now I have ran into a problem that if the first row in the gridview is selected the SelectionChange will not fire. Can someone please help me determine how I detect if the first row is the row is selected?
modified 7-Sep-16 14:57pm.
|
|
|
|
 |
I did find the ListView UnselectAll() function but even that did not work.
|
|
|
|
 |
Has anyone ever seen this? I have a Listbox control:
<ListBox Grid.Row="3" Grid.ColumnSpan="3" Margin="3" SelectionMode="Multiple"
ItemsSource="{Binding Children}" SelectedItem="{Binding SelectedChild}" SelectionChanged="Children_SelectionChanged">
And there is a property IsSelected in the class that selecting an item changes correctly.
I also have a "Select All" button and an "Unselect All" button which seem to work. After pressing the button and counting the selected objects I get the expected counts.
Now my listbox has more items than fit in the view area, so the scroll bars appear.
The problem comes when I press the select all button and then scroll the list box. Even though my count said they were all selected, after I scroll, the items that were not in the window at the time the button was pressed revert to their prior state. The IsSelected property is re-called by the scrolling.
I don't know if I can make it any clearer. How do I keep the scroll bar from resetting the IsSelected property? Or How can I get the listbox to keep the items outside the visual area selected or unselected?
Thanks for any help.
Brent
|
|
|
|
 |
This has always confused me and I would love to set the record straight.
Say you have this style:
<Style TargetType="{x:Type local:ControlBasedOnUserControl}">
<Setter Property="Width" Value="50" />
<Setter Property="Height" Value="50" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:ControlBasedOnUserControl}">
<Border>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Does WPF automatically apply the width and height of the control to the template's parent element or should the width and height be bound explicitly in the template?
<Style TargetType="{x:Type local:ControlBasedOnUserControl}">
<Setter Property="Width" Value="50" />
<Setter Property="Height" Value="50" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:ControlBasedOnUserControl}">
<Border Width="{TemplateBinding Width}" Height="{TemplateBinding Height}">
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
I've found that I can set a width and height regardless if it is explicitly defined in template, but that doesn't seem right. Thoughts?
|
|
|
|
 |
I have a Telerik RadCombobox where I need to react to the change of selected item and store the selected value.
<telerik:RadComboBox ItemsSource="{Binding CurrencyList}"
DisplayMemberPath="Currency"
SelectedValuePath="CurrencyID"
SelectedValue="{Binding SelectedIssuance.IssuanceCurrencyID, Mode=TwoWay}"
IsSynchronizedWithCurrentItem="True"
SelectedItem="{Binding SelectedCurrency,Mode=OneWayToSource}" />
This works the first time I access the view, however subsequent accesses on the same or another record the displayed value is always the first record in the CurrencyList
Any suggestions on how to fix this issue?
One idea is to get the changed value in the VM from the Model by subscribing to the OPC event and remove the SelectedItem binding.
Never underestimate the power of human stupidity
RAH
|
|
|
|
 |
I have been fighting with the OpenFileDialog to try to read the bytes of any type of file into a stream or byte[] to store in a database table but can't seem to get it right. Is using the OpenFileDialog class the correct way to go?
|
|
|
|
 |
With the OpenFileDialog, the only property you're going to want to really use is the Filename. Once you have this, you would fall back to standard File operations to read the bytes (ReadAllBytes would be the one I would choose).
This space for rent
|
|
|
|
 |
How find out size of "files" or each element(foreach (var file in files)) if files list? Could be quite big.
WPF serialization doesnt work in UWP.
var openPicker = new FileOpenPicker();
openPicker.FileTypeFilter.Add("*");
var files = await openPicker.PickMultipleFilesAsync();
modified 27-Aug-16 11:08am.
|
|
|
|
 |
You use code similar to this:foreach (StorageFile file in files)
{
BasicProperties properties = await file.GetBasicPropertiesAsync();
ulong size = properties.Size;
}
This space for rent
|
|
|
|
 |
Message Removed
modified 26-Aug-16 20:43pm.
|
|
|
|
 |
My problem is very difficult to describe but this is what I am trying to do. See all code below. What I have is a parent WPF Window that has a child View, created as a UserControl, added to the parent Window in it's markup. Now the problem is this. When a row, on the child UserControl View's GridView is clicked I want to close the child view's parent (Window) then navigate to an entirely new Window and open it. When I click the row I get the error 'Invalid cast exception". See below:
Static class defined in the same namespace:
public static class closeWindow
{
public static object WinObject;
public static void CloseParent()
{
using ((System.IDisposable)closeWindow.WinObject)
{
((Window)WinObject).Close();
}
}
}
Markup in the XAML parent Window page:
modified 23-Aug-16 9:38am.
|
|
|
|
 |
The fix was instead of using a Using() block of code I changed it to a try/catch:
try ((System.IDisposable)closeWindow.WinObject)
{
((Window)WinObject).Close();
}
catch(Exception e)
{
}
|
|
|
|
 |
The Window class[^] does not implement IDisposable. Neither do any of it's base classes. Therefore, you cannot cast a Window to IDisposable.
Why have you declared the field as an object if it's only ever going to store a Window? Just declare it as Window and avoid the cast.
Your CloseParent method needs to check whether the field has a value; otherwise, you could end up with a NullReferenceException.
You should probably set the field back to null once the window has been closed.
And you could save yourself a lot of trouble by avoiding the static class, and using the Window.GetWindow method[^] instead:
Intake1 window = new Intake1();
window.Show();
Window parentWindow = Window.GetWindow(this);
if (parentWindow != null) parentWindow.Close();
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
 |
I'm new to WPF/MVVM and have been trying to come up with a solution for communicating between ViewModels. The best i've been able to come up with is below, it works, but it feels dirty and shameful. Any suggestions would be greatly appreciated.
public delegate void OnMessageReceivedEventHandler(object sender, object message);
public static class Message
{
static List<OnMessageReceivedEventHandler> listeners = new List<OnMessageReceivedEventHandler>();
public static void AddListener(OnMessageReceivedEventHandler onMsgReceived)
{
listeners.Add(onMsgReceived);
}
public static void RemoveListener(OnMessageReceivedEventHandler onMsgReceived)
{
listeners.Remove(onMsgReceived);
}
public static void SendMessage(object sender, object msg)
{
foreach (OnMessageReceivedEventHandler m in listeners)
if (m != null)
m(sender, msg);
}
}
Nothing works better than just improving your product.
|
|
|
|
 |
The generally accepted method for communicating between VMs is to use a Mediator or Messenger. If you take a look at MVVM Light, for instance, you can see how to write one and how to use it.
This space for rent
|
|
|
|
|
 |
In addition to Pete's answer, you could also use Rx to communicate between viewmodels.
Sacha uses that here: Attached VM Behaviours[^]
|
|
|
|
 |
Hello everybody,
I am struggling with the decision how to design my application. Let me describe my problem:
The application has a navigation on the left and the region to display the according view to the right.
It shall load projects and those projects can be of type A, B or C. The navigation is the same for all types, but some of the views differ.
My plan was for all type depending items in the navigation to have a general view which offers a region and the modules A, B and C which all provide a view for that region. During the loading of the project depending on its type the module / library A, B or C is loaded while the other library is unloaded. But I found out it is not supported to unload modules (only complete AppDomains).
I am developing in C# using VS 2010 and Prism 4.0.
Anyone has an idea how to best solve this issue? Is creating and unloading a temporary AppDomain really the best solution?
|
|
|
|
 |
I have no idea of what your app is supposed to do, but in my "apps", I often simply toggle the visibility of a component instead of worrying about "loading" and "unloading" UI elements.
|
|
|
|
 |
Thank you for your proposal Gerry, that is pretty much what I'll be doing now.
Each library checks if it is applicable for the current type and sets the view's visibility accordingly.
This does not really make me happy as I have to load all assemblies, but it is the best solution I can think of right now.
|
|
|
|
|