SketchFlow how to set button enabled true/false with behavior - expression-blend

I was trying to figure out if it is possible to set the Enabled property of a button with a ChangeProperty behavior in SketchFlow/ExpressionBlend. It doesn't appear that the Enabled property is available in the behavior.
thanks!
Bill

Here is xaml that does what you mention above (in silverlight). It works the same way in WPF. The property is named IsEnabled if that is the source of confusion:
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
x:Class="SilverlightApplication7.MainPage"
Width="640" Height="480">
<Grid x:Name="LayoutRoot" Background="White">
<Button x:Name="button" Content="Button" HorizontalAlignment="Left" Height="58" Margin="225,124,0,0" VerticalAlignment="Top" Width="79"/>
<Button Content="Button" HorizontalAlignment="Left" Margin="225,230,0,207" Width="50">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<ei:ChangePropertyAction TargetName="button" PropertyName="IsEnabled" Value="False"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
</Grid>
</UserControl>

Related

Dark theme of app

I writing application for Windows phone.
I want to set dark theme of app.
I set it on this window, but when I deploy this app on device, my theme is light.
Theme
Code of my xaml:
<Page
x:Class="Murakami.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Murakami"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Button x:Name="button" Content="" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Width="48" Height="46">
<Button.Background>
<ImageBrush Stretch="Fill" ImageSource="Images/menu.png"/>
</Button.Background>
</Button>
<Button x:Name="button1" Content="" HorizontalAlignment="Left" Margin="302,10,0,0" VerticalAlignment="Top" Width="48" Height="46" >
<Button.Background>
<ImageBrush Stretch="Fill" ImageSource="Images/cart.png"/>
</Button.Background>
</Button>
<Button x:Name="button2" Content="" HorizontalAlignment="Left" Margin="126,5,0,0" VerticalAlignment="Top" Height="63" Width="115">
<Button.Background>
<ImageBrush Stretch="Fill" ImageSource="Images/logo_murakami.png"/>
</Button.Background>
</Button>
</Grid>
How I can fix this?

Universal Windows 10 - How to add button in title bar like Microsoft Edge?

I use Extend View into titlebar like this:
CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true;
And my Xaml code is:
<Page
x:Class="ProjectX.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:ProjectX"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid Background="#263238" Height="32" VerticalAlignment="Top" RequestedTheme="Dark">
<TextBlock Text="Title Bar" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<Button Width="50" Height="32" Click="Button_Click"/>
</Grid>
<TextBlock x:Name="txtTest" Text="AAAAAAAAAA" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="Black"/>
</Grid>
The button can't click. Help me!
You can add the back button
using Windows.UI.Core;
var currentView = SystemNavigationManager.GetForCurrentView();
currentView.AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
You have a full description here: https://marcominerva.wordpress.com/2015/05/19/easily-manage-the-title-bar-in-windows-10-apps/
In short, what you miss is that you must call a Window.Current.SetTitleBar method to set that only that control is used to handle window operations, while other controls will receive input regularly.

Xaml designer behaves differently in VS 2012 and VS 2010

I recently switched to Visual Studio 2012 from VS2010.
I have some user controls which are templates for other user controls.
The first ones have some ContentControl whose content is defined in the second ones.
Follows the definition of a user control based on a template control (ImpegniBaseView)
<localView:ImpegniBaseView>
<localView:ImpegniBaseView.ActionButtons>
<StackPanel Height="54" HorizontalAlignment="Left" VerticalAlignment="Top" Width="668" Orientation="Horizontal">
<Button Content="Salva" Height="31" Width="88" Command="{Binding Path=SaveCommand}" IsEnabled="{Binding Editable}" Margin="5,0" />
<Button Command="{Binding Path=CreateCommand}" Content="Nuovo impegno master" Height="31" Width="Auto"
Visibility="{Binding IsFirstLevelView, Converter={StaticResource BoolToVisibility}}"
IsEnabled="{Binding Path=Editable, Converter={StaticResource InverseBooleanConverter}}" Margin="5,0" />
</StackPanel>
</localView:ImpegniBaseView.ActionButtons>
</localView:ImpegniBaseView>
In Vs 2010 I could easily select, for example, the button 'Salva' in the designer. Now I cannot. I suppose I have to change an option in the designer, but I don't know which one...
Update
Follows the relevant part of the user control used as template
<UserControl x:Class="Ragioneria.View.ImpegniBaseView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Ragioneria"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="700">
<DockPanel DataContext="{Binding ImpegnoSelezionato}">
<DockPanel DockPanel.Dock="Top">
<StackPanel Orientation="Horizontal" DockPanel.Dock="Left">
<Label Content="Anno/Num-Sub" Height="28" HorizontalAlignment="Left" Margin="5" Name="label1" VerticalAlignment="Top" Width="Auto" />
<ContentControl Content="{Binding Path=IdentificazioneImpegnoSection, RelativeSource={RelativeSource AncestorType=UserControl}}" Width="400" Height="28" Margin="5" />
</StackPanel>
<TextBox Height="28" Width="100" Name="textBox9" Text="{Binding Path=DataRegistrazione, StringFormat=d}" DockPanel.Dock="Right" Style="{DynamicResource tb_readonly}" TextAlignment="Right" Margin="5" />
<Label Content="Data" Height="28" Margin="5" Name="label7" Width="50" DockPanel.Dock="Right"/>
</DockPanel>
<ContentControl DockPanel.Dock="Bottom"
DataContext="{Binding DataContext.ActiveWorkspace, RelativeSource={RelativeSource AncestorType=Window}}"
Content="{Binding Path=ActionButtons, RelativeSource={RelativeSource AncestorType=UserControl}}" />
</DockPanel>
Thanks
Filippo
You must add [AlternateContentProperty] to ActionButtons.
Unfortunately, unlike in Silverlight, you won't find this attribute in standard library.
Instead, you will need to use Microsoft.Windows.Design.PropertyEditing.AlternateContentProperty from Microsoft.Windows.Design.Interaction.dll.
Since this is a non-redistributable dll from Visual Studio, you can't reference it directly and have to create designer metadata assembly.
See this bug
and vote here.

Textwrapping issu for a UserControl inside Popup

I have a user control that inside has a TextBlock (textmsg), the following is the xaml file
<UserControl x:Class="XXXXX.MyMsgBox"
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"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
d:DesignHeight="400" d:DesignWidth="480">
<Grid x:Name="LayoutRoot" Background="#FF000000">
<StackPanel HorizontalAlignment="Left" Name="stackPanel2" VerticalAlignment="Top" Margin="10">
<TextBlock Margin="10" Name="textmsg" Text="{Binding Path=LocalizedResources.wb_msg, Source={StaticResource LocalizedStrings}}" TextWrapping="Wrap" />
<StackPanel Name="stackPanel1" Orientation="Horizontal">
<Button Width="140" Content="{Binding Path=LocalizedResources.set_wb, Source={StaticResource LocalizedStrings}}" Name="button1" Click="button1_Click" FontSize="22" />
<Button Width="170" Content="{Binding Path=LocalizedResources.default_wb, Source={StaticResource LocalizedStrings}}" Name="button2" FontSize="22" />
<Button Width="140" Content="{Binding Path=LocalizedResources.cancel, Source={StaticResource LocalizedStrings}}" Height="72" Name="button3" FontSize="22" />
</StackPanel>
</StackPanel>
</Grid>
</UserControl>
then in C# I use the following code to display the popup
Popup popup = new Popup();
MyMsgBox mmb = new MyMsgBox(popup);
popup.Height = 400;
popup.VerticalOffset = 328;
popup.HorizontalOffset = 0;
popup.Child = mmb;
popup.IsOpen = true;
but the text inside textmsg isn't wrapped, why ? What is wrong?
Best regards.
You should set the MaxWidth property on the parent (StackPanel) of your TextBlock (textmsg). StackPanel sizes to whatever its content asks for, and gives free reign for the content to ask for anything. Thus, the TextBlock asks for the full width of the text with no wrapping.

WPF 4.0 AutoCompleteBox TwoWay Binding

I have a WPF window that has several Listbox and DataGrid controls. The main Listbox displays a list of Contractors. An Address(s) datagrid is bound to the Contractor ListBox and displays address(s) for the current selected Contractor.
I want users of this Window(WPF) to be able to add Addresses to the selected Contractor using the native Datagrid Add functionality. I also want the users to be able to edit associated Address records by clicking in the datagrid cell and having the cell function as an AutoCompleteBox.
I have partially successfully implemented the AutoCompleteBox in the State column of the datagrid control. Currently, the correct Text value for the current Contractor is displayed in the State column of the Address datagrid. If i edit the State cell I get expected autocomplete functionality and I can select a new State.
What is not working is the TwoWay binding. Currently, if I change the current Address state it does not save back to the entity model or the db. Its not surprising since I know I dont have Twoway binding implemented correctly on this control.
I have successfully implemented the Twoway binding with a combobox but the combobox obviously does not provide the autocomplete functionality I need.
Update
We worked on this late yesterday and arrive at a partial solution. Now we have a new issue.
With a ComboBox you can have:
DisplayMemberPath ="StateAbbrv"
SelectedValue="{Binding Path=tbl_Address.StateID, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" and
SelectedValuePath="StateID".
With the AutoCompleteBox it seems you really only have:
ValueMemberPath="StateID" and
Text="{Binding Path=tbl_Address.StateID, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource StateConverter}}" Grid.Column="1" Grid.Row="1" Margin="0,0,0,0" >
With the AutoCompleteBox you can’t have separate display and selected values. Because of my Window control binding and database structure I need to display a string value such as “CA California” while actually having a selected table key integer value in the background.
To be clear, we need to have separate Display and Selected values in the Text part of the AutoCompleteBox control.
Here is the Master ListBox displaying Contractors:
<Grid DataContext="{StaticResource tbl_PartnerViewSource}" HorizontalAlignment="Left" Name="grid3" VerticalAlignment="Top" Height="242" Width="295" Grid.Column="1" Margin="0,1,0,0" Grid.Row="3">
<Grid.RowDefinitions>
<RowDefinition Height="31*" />
<RowDefinition Height="211*" />
</Grid.RowDefinitions>
<Label Content="Contractor List" FontWeight="Bold" Height="25" Margin="0,0,169,0" Name="label10" Padding="3" VerticalAlignment="Top" />
<ListBox DisplayMemberPath="tbl_Organization.OrgName" Height="212" HorizontalAlignment="Right" ItemsSource="{Binding}" Margin="0,30,0,0" Name="orgNameListBox" SelectedValuePath="PtnrID" VerticalAlignment="Center" Width="294" IsSynchronizedWithCurrentItem="True" Grid.RowSpan="2" SelectionChanged="orgNameListBox_SelectionChanged" TabIndex="11" MouseDoubleClick="orgNameListBox_MouseDoubleClick" DataContextChanged="orgNameListBox_DataContextChanged" SourceUpdated="orgNameListBox_SourceUpdated" IsManipulationEnabled="True" />
</Grid>
Here is the Stack Panel containing the Datacontext supporting the controls in discussion:
<StackPanel Grid.Row="3" Height="243" HorizontalAlignment="Left" Name="stackPanel5" VerticalAlignment="Top" Width="295" Grid.Column="1"></StackPanel>
<Label Content="Address(s)" FontWeight="Bold" Height="25" HorizontalAlignment="Left" Margin="306,0,0,0" Name="label1" Padding="3" VerticalAlignment="Top" Width="648" Grid.Column="1" Grid.Row="1" />
<DataGrid Name="dataGridAddress" DataContext="{StaticResource tbl_Partnertbl_PartnerAddressViewSource}" ItemsSource="{Binding}" SelectionMode="Single" SelectionUnit="CellOrRowHeader" AutoGenerateColumns="False" AlternatingRowBackground="#FFFF003B" AlternationCount="2" Grid.Column="1" Grid.Row="1" HorizontalAlignment="Left" Margin="308,22,0,0" Width="649" Height="113" VerticalAlignment="Top" CanUserDeleteRows="True" CanUserAddRows="True">
<DataGrid.Columns>...
Here is the AutoCompleteBox that is partially working:
<DataGridTemplateColumn x:Name="addState" Header="State" Width="100">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<my1:AutoCompleteBox Name="autoCompleteBox1"
IsTextCompletionEnabled="True"
ItemsSource="{Binding Source={StaticResource tbl_StateViewSource}}"
ValueMemberPath="StateID"
Text="{Binding Path=tbl_Address.StateID, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Grid.Column="1" Grid.Row="1" Margin="0,0,0,0" >
<my1:AutoCompleteBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Path=StateAbbrv}" Width="30" FontWeight="Bold" Margin="0,0,0,0" />
<TextBlock Text="{Binding Path=StateName}" />
</StackPanel>
</DataTemplate>
</my1:AutoCompleteBox.ItemTemplate>
</my1:AutoCompleteBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
Here is the Combobox with working TwoWay binding:
<GridViewColumn x:Name="addrState" Header="State" Width="75">
<GridViewColumn.CellTemplate>
<DataTemplate>
<ComboBox Name="comboAddressState" SelectedValue="{Binding Path=tbl_Address.StateID, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Margin="{StaticResource Margin2}" DisplayMemberPath="StateAbbrv" SelectedValuePath="StateID" ItemsSource="{Binding Source={StaticResource tbl_StateViewSource}}" IsSynchronizedWithCurrentItem="False" IsEnabled="True" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
Here is the Windows.Resource Section:
<Window.Resources>
<CollectionViewSource x:Key="tbl_PartnerViewSource" d:DesignSource="{d:DesignInstance my:tbl_Partner, CreateList=True}"></CollectionViewSource>
<CollectionViewSource x:Key="tbl_Partnertbl_PartnerAddressViewSource" Source="{Binding Path=tbl_PartnerAddress, Source={StaticResource tbl_PartnerViewSource}}" />
<CollectionViewSource x:Key="tbl_Partnertbl_PartnerContactViewSource" Source="{Binding Path=tbl_PartnerContact, Source={StaticResource tbl_PartnerViewSource}}" />
<CollectionViewSource x:Key="tbl_Partnertbl_PartnerContacttbl_PartnerContactCommChanAddrViewSource" Source="{Binding Path=tbl_PartnerContactCommChanAddr, Source={StaticResource tbl_Partnertbl_PartnerContactViewSource}}" />
<CollectionViewSource x:Key="tbl_Partnertbl_PartnerSystemViewSource" Source="{Binding Path=tbl_PartnerSystem, Source={StaticResource tbl_PartnerViewSource}}" />
<CollectionViewSource x:Key="tbl_Partnertbl_PartnerAliasViewSource" Source="{Binding Path=tbl_PartnerAlias, Source={StaticResource tbl_PartnerViewSource}}" />
<CollectionViewSource x:Key="tbl_Partnertbl_PartnerCommentViewSource" Source="{Binding Path=tbl_PartnerComment, Source={StaticResource tbl_PartnerViewSource}}" />
<CollectionViewSource x:Key="tbl_ServicedCustomerViewSource" d:DesignSource="{d:DesignInstance my:tbl_ServicedCustomer, CreateList=True}" />
<CollectionViewSource x:Key="tbl_SystemViewSource" d:DesignSource="{d:DesignInstance my:tbl_System, CreateList=True}" />
<CollectionViewSource x:Key="tbl_PlatformViewSource" d:DesignSource="{d:DesignInstance my:tbl_Platform, CreateList=True}" />
<CollectionViewSource x:Key="tbl_ManufacturerViewSource" d:DesignSource="{d:DesignInstance my:tbl_Manufacturer, CreateList=True}" />
<CollectionViewSource x:Key="tbl_StateViewSource" d:DesignSource="{d:DesignInstance my:tbl_State, CreateList=True}" />
<CollectionViewSource x:Key="tbl_ZIPViewSource" d:DesignSource="{d:DesignInstance my:tbl_ZIP, CreateList=True}" />
<CollectionViewSource x:Key="tbl_CityViewSource" d:DesignSource="{d:DesignInstance my:tbl_City, CreateList=True}" />
<Thickness x:Key="Margin1">8,-3,-7,-3</Thickness>
<Thickness x:Key="Margin2">-7,-3,-7,-3</Thickness>
</Window.Resources>
Here is a image of the Window(WPF):

Resources