|
Sounds like you're saying that every property on every model should call property changed?
Everything makes sense in someone's mind
|
|
|
|
|
Only the ones that change.
|
|
|
|
|
This may be caused by not have OnPropertyChanged implemented in your model (item in the list).
Our first design had the model in the WCF, this did not allow the event in the model to be used by the view. By moving the models into a separate project that is referenced by both the WCF and the UI we not get the events on the items.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
A short time ago, I started learning WPF (with C#). I learned how to create styles and to embed them.
My style contains
<Style x:Key="RoundedButton" TargetType="{x:Type Button}" BasedOn="{StaticResource {x:Type Button}}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Grid>
<Rectangle Fill="{TemplateBinding Background}" Stroke="Black" RadiusX="8" RadiusY="8"/>
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="Background" Value="{StaticResource GreenGradientBrush}"/>
<Style.Triggers>
<Trigger Property="Button.IsFocused" Value="true">
<Setter Property = "Background" Value="{StaticResource RedGradientBrush}"/>
</Trigger>
<Trigger Property="Button.IsMouseOver" Value="true">
<Setter Property = "Background" Value="{StaticResource GoldGradientBrush}"/>
</Trigger>
</Style.Triggers>
</Style>
<Style x:Key="AcceptButton" TargetType="{x:Type Button}" BasedOn="{StaticResource RoundedButton}">
<Setter Property="Background" Value="{StaticResource BlueGradientBrush}"/>
<Setter Property="Content" Value="_OK" />
<Setter Property="IsDefault" Value="true" />
</Style>
When I add the AcceptButton to a Window, the underline of "_OK" shows up, and clicking ALT+O does not have any effect.
How can I get the accelerator key working?
|
|
|
|
|
Your template is missing something. Change your ContentPresenter so that you use the access key. All you need to do is add RecognizesAccessKey="True" like this:
<ContentPresenter RecognizesAccessKey="True" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
|
|
|
|
Thanks! That did the trick.
|
|
|
|
|
No problem. Glad I could help.
|
|
|
|
|
I have a viewModel which is used to bind to a user control. The user control is basically a AdRotator. One of the feature of AdRotator is that it can be used in multiple positions on same screen. Seperate set of ads will be displayed on these multiple adRotators. The single view model exposes 4 observable collections which is deputed for adRotators on various locations . My problem is that since user controls are 'drag n drop' use i am a looking for a identification method that will let me determine which observablecollection(of the 4) should the an adRotator bind to. Please let me know what are the approaches for this.
Will it be a good approach if i retrieve the name of the user control and bind the collection depending on the name?
|
|
|
|
|
I would change your design approach slightly. There's no need for you to maintain four ObservableCollection properties in your code. In reality, you only need one, and this should be filled based on the choice that needs to be displayed. A simple method to do this would be to use something like an enumeration to define what needs to be loaded, and expose that as a property of your user control.
|
|
|
|
|
in the following XAML:
<UserControl x:Class="NextImage2.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="400">
<Grid x:Name="LayoutRoot">
<Grid.Background>
<LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
<GradientStop Color="Black" Offset="0" />
<GradientStop Color="White" Offset="1" />
</LinearGradientBrush>
</Grid.Background>
<Image Name="image1" Stretch="Fill" Source="file:///C:/Program Files (x86)/Telerik/RadControls for Silverlight Q2 2011/Demos/Examples/Slider/Images/Slider/Image1.PNG" Margin="49,29,0,0" HorizontalAlignment="Left" Width="304" Height="245" VerticalAlignment="Top" />
</Grid>
</UserControl>
the image is displayed in design mode, but is not displayed in runtime, neither in browser nor out of browser.
why it may be?
P.S. replace the face with colon d!
|
|
|
|
|
i found that i didn't add the image to my project. it's just an image which exists somewhere in my HDD.
but, the matter is that i don't want to put a static image there.
consider a program which is written and doesn't intend to know what is the image. by clicking on the default image a file open dialog must be opened from which user may select the image he/she wants to be shown in the Image control.
also consider a case in which the image must be made dynamically. maybe something like a simple MSPaint. user may just draw lines or put points. it's enough that the image not to be static anymore.
what can i do in such cases?
thx
|
|
|
|
|
One of the things to remember when running your application is that it has to respect the permission sets applied, so the fact that you are attempting to read the image from a folder that you will not normally have the permissions to get to is going to cause you a problem.
If your application needs to be able to display an image chosen by the user, a simple way to do this is to read the picture in programatically and display that.
|
|
|
|
|
In my ResourceDictionary I have this
<Style x:Key="BaseControlStyle"
TargetType="UserControl">
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="VerticalAlignment" Value="Center"/>
</Style>
<Style x:Key="CheckBoxStyle"
TargetType="CheckBox"
BasedOn="{StaticResource BaseControlStyle}">
</Style>
The CheckBox is not being vertically centered. If I move the VerticalAlignment setter into the CheckBox style, then it works. Anyone know what I'm doing wrong?
Everything makes sense in someone's mind
|
|
|
|
|
I am building a WPF app. There will be"tiles" that will contain an image and some text. The user wants to drag these tiles onto the window/work area. What's the best design approach for this? Each type of tile will have its owns et of properties. I can use a dialog for that. I will proably use a canvas as the design area.
But what's the right way to do the tiles? There will be s distinct set of tiles that I create at design time. Should I make them user controls and allow the user to drag them on? I could create them as images and use an enum to determine the type the user is gradding.
I'v never done something like this before, so I'm open to suggestion.
Thanks
Everything makes sense in someone's mind
modified 15-Feb-12 20:59pm.
|
|
|
|
|
If I needed to do something like that, I would probably steal code from one of these places and modify / clean it up:
WPF Diagram Designer - Part 4[^]
Dragging Elements in a Canvas[^]
As for the properties, I wouldn't use a dialog for that. I'd use a property grid. Not as nice, but I wouldn't want to spend the rest of life adding / removing / editing those dialogs when the property grid can do it automatically.
|
|
|
|
|
That's exactly what I'm looking for.
Thanks!
Everything makes sense in someone's mind
|
|
|
|
|
I'm not totally sure how to ask this question, so bear with me...
I have a data template for a list of ProjectEntities displayed in a ListBox. A ProjectEntity has ProjectName and ProjectType properties, both string.
So far, my data template contains a hyperlink for the ProjectName and a combobox populated with a list of ProjectType. I have the combobox itemsource set in the template, it it's populating fine.
But how do I set the combo box selected item on the selected listbox item? In other words, on each instance of a ProjectEntity, I need to know what combobox value was selected.
Here's my XAML so far:
<DataTemplate DataType="{x:Type entities:ProjectEntity}">
<StackPanel Orientation="Horizontal"
Margin="2">
<Image Source="/Falcon.WPF;component/Media/Images/project_256.png"
Height="16"
Width="16"
Margin="0,0,2,0"/>
<TextBlock Margin="2,0,0,0"
Width="200">
<Hyperlink NavigateUri="{Binding ProjectName}"
Foreground="RoyalBlue"
Command="{Binding Path=DataContext.SelectedProjectCommand,
RelativeSource={RelativeSource FindAncestor, AncestorType={ x:Type views:ClientListView}}}"
CommandParameter="{Binding}">
<InlineUIContainer>
<TextBlock Text="{Binding ProjectName}" />
</InlineUIContainer>
<Hyperlink.Style>
<Style TargetType="Hyperlink">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="False">
<Setter Property="TextDecorations" Value="{x:Null}" />
</Trigger>
</Style.Triggers>
</Style>
</Hyperlink.Style>
</Hyperlink>
</TextBlock>
<ComboBox ItemsSource="{Binding Path=DataContext.ProjectTypes,
RelativeSource={RelativeSource FindAncestor, AncestorType={ x:Type views:ClientListView}}}"
Width="100"/>
</StackPanel>
</DataTemplate>
Everything makes sense in someone's mind
|
|
|
|
|
Wouldn't you just have a ProjectType obejct in your ProjectEntity and bind that to the ComboBox SelectedItem in two-way mode?
|
|
|
|
|
Ok, I have this
<ComboBox ItemsSource="{Binding Path=DataContext.ProjectTypes,
RelativeSource={RelativeSource FindAncestor, AncestorType={ x:Type views:ClientListView}}}"
SelectedItem="{Binding Path=DataContext.SelectedProjectType,
RelativeSource={RelativeSource FindAncestor, AncestorType={ x:Type views:ClientListView}}, Mode=TwoWay}"/>
The property in the VM is being set, but it seems like I would need some logic somewhere to know which ProjectEntity the user was changing.
Can you elaborate a bit?
Thanks
Everything makes sense in someone's mind
|
|
|
|
|
Doesn't each item in your ListBox have a ComboBox? That's what it looks like from your XAML. So each item in the ListBox would need to have a SelectedProjectType and you would bind to the item one, not the view one.
|
|
|
|
|
I'm giving a try to VisualState in my template for a WP7 app.
I have an ExpanderView and I'd like to have a little arrow in the header showing the state (expanded or not) and rotate it smootly from up to down when IsExpanded change value.
I have an attached property WpfUtils.VState which call VisualStateManager.GoToState(target) when a binded value change.
1st problem it should target a Control but I'm trying to update an Image ...
I "worked around it" (hopefully, doesn't work anyway) by templating the container object.
2nd problem, it's just not working!
Here is my XAMl, any idea?
<toolkit:ExpanderView
x:Name="eview"
gwpf:WpfUtils.VState="{Binding IsExpanded, Converter={StaticResource ccvt}, RelativeSource={RelativeSource Self}}"
>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="MyStates">
<VisualState x:Name="MyCollapsedState"/>
<VisualState x:Name="MyExpandedState">
<Storyboard>
<DoubleAnimation
Storyboard.TargetProperty="Header.RenderTransform.Angle"
Duration="0:0:0.5" From="-90" To="90"/>
<!--
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<toolkit:ExpanderView.Header>
<StackPanel Orientation="Horizontal">
<Image Width="36" locv:ThemedImage.Path="appbar.next.rest.png" RenderTransformOrigin="0.5,0.5">
<Image.RenderTransform>
<RotateTransform x:Name="ArrowExpandT" Angle="-90"/>
</Image.RenderTransform>
</Image>
<TextBlock
Text="{Binding Local.NewItem, Source={StaticResource strings}}"
FontSize="{StaticResource PhoneFontSizeLarge}"
VerticalAlignment="Center" Margin="8"/>
</StackPanel>
</toolkit:ExpanderView.Header>
<StackPanel Orientation="Vertical">
<locv:ItemView x:Name="NewItemUI" />
<!--
<Button
VerticalAlignment="Bottom" HorizontalAlignment="Right"
Content="{Binding Local.Add, Source={StaticResource strings}}"
Click="DoAddItem"/>
</StackPanel>
</toolkit:ExpanderView>
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
Hi,
I have a silver light application. I have some master data in database which is using extensivly on application especially when i print crystal reports. So i decided to store data on Server( through session etc) or on client to avoid database trips. I want to ask which is best option from perfomance point of view
Option 1: Store all data on server( through session or application variables etc) and get data from server when needed for example while printing reports( I am using Crystal Reports12)
Option2: Store all data on client ( e.g create a collection in silverlight on client and store all currencies in that collection) and when i want to print report and want to use that data pass this data( currency collection) to server along with other data( other arguments needed on server) through WCF services ( I am using WCF Services)
Thanks
|
|
|
|
|
You should also look at the Isolated Storage option.
Here, you can store some amount of data (so long as it is not too large) and make it persist for some time (unless the client clears this storage area).
|
|
|
|
|
Thank you for suggestion. I want to get/transfer this data from database when user login and clears out when he log off ( As data may be change any time). Should i still consider Isolated storage option? and second thing storing data in Isolated storage means transfer data on client is good option . Am i right?
Thank you & Best regards
|
|
|
|
|
If the data is liable to change during the use of the application then you shouldn't really consider storing it in isolated storage. Take, for instance, stock prices - these change rapidly, so the data for this should be retrieved from elsewhere (e.g. a web service, or database if you are the one controlling the stock prices). If the setting is something like a user preference, then it does make sense to store this locally, but with it synchronised back to the server when the user updates it.
|
|
|
|