我在这里检查了很多MEF问题,但我无法想象我的问题是什么.这是发生了什么:
我有一个桌面WPF应用程序,我正在部署AdvancedInstaller.我使用.NET 4.0和MEF来组成部件.某些部分位于主项目中,因此它们位于app.exe文件中.其他部分是引用主项目的类库内部,因此它们位于somename.dll文件中.
问题:从VS运行应用程序时,无论是在Debug还是在Release中,一切都很好.一旦我部署应用程序,一些dll说他们没有部分(零)导出.
我检查了以下内容:
这是在部署的应用程序中找不到部分的代码:
var catalog = new AggregateCatalog();
string path = Environment.CurrentDirectory.ToString();
DirectoryCatalog qualitycontrol = new DirectoryCatalog(".", "QualityControl.exe"); //this is my main assembly
DirectoryCatalog qualitymix;
catalog.Catalogs.Add(qualitycontrol); //this finds the parts and always works fine
if (File.Exists(path + @"\QualityMix.dll"))
{
qualitymix = new DirectoryCatalog(".", "QualityMix.dll"); //the file exists in the deployment
catalog.Catalogs.Add(qualitymix); //the "qualitymix" catalog shows more than 20 parts if run with VS, but 0 parts in deployment
}
Run Code Online (Sandbox Code Playgroud)
唯一可行的(但启动应用程序的速度非常慢)如下:
var catalog = …Run Code Online (Sandbox Code Playgroud) 我在一个ResourceDictionary带有图像的按钮中定义了一个样式:
<Style x:Key="BotonIrAInicioStyle" TargetType="Button">
<Setter Property="Margin" Value="0"/>
<Setter Property="Width" Value="{Binding RelativeSource={RelativeSource Self}, Path=ActualHeight}"/>
<Setter Property="Content">
<Setter.Value>
<Image Margin="2" Source="{StaticResource IconoDashboardBlanco}" MaxHeight="20" Stretch="Uniform"
RenderOptions.BitmapScalingMode="HighQuality"/>
</Setter.Value>
</Setter>
</Style>
Run Code Online (Sandbox Code Playgroud)
图像源ResourceDictionary在同一个程序集中的另一个中定义,并标记为x:Shared="False":
<BitmapImage x:Key="IconoDashboardBlanco" x:Shared="False"
UriSource="pack://application:,,,/QualityFramework;component/Images/dashboard64X64.png"/>
Run Code Online (Sandbox Code Playgroud)
由于样式将用于不同的程序集,我使用"pack://application:,,,"符号来引用图像.在Build Action对图像设置Resource (Do not copy to output directory).
在主程序集中,我有两个UserControls显示相同样式的按钮:
<Button DockPanel.Dock="Left" Style="{StaticResource BotonIrAInicioStyle}" Click="BotonIrAInicio_Click"/> (Click event has nothing to do with the problem)
Run Code Online (Sandbox Code Playgroud)
问题:
我打开UserControl A包含图像的按钮,图像显示确定.然后我打开UserControl B包含一个相同的按钮,图像确定.我UserControl A再次打开,图像消失了.如果我打开UserControl …
我有一个显示项目列表的组合框,我想在它旁边放一个按钮,触发命令查看所选项目的详细信息.到现在为止还挺好.现在我希望只有在组合框具有焦点(或处于"编辑"模式,但不仅仅是弹出窗口打开时)时按钮才可见.
我以为我可以将按钮的可见性绑定到组合框的某些焦点属性,如下所示:
<Button Content="Details" Visibility="{Binding ElementName=elementListComboBox,
Path=IsFocused, Converter={StaticResource Bool2VisibilityConverter}}"/>
Run Code Online (Sandbox Code Playgroud)
但我发现无法知道我想要的控制是否有重点.我查看了FocusManager.FocusedElement,但我不知道如何在绑定中获得我想要的聚焦控件.有没有办法在XAML中实现这一目标?
我创建了一个 ObservableCollection<T> ,每当集合中对象的属性 (T: INPC) 发生更改时,它都会触发 CollectionChangedEvent。我想知道 T 的哪个属性触发了 CollectionChangedEvent,所以我尝试了以下操作:
void item_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset, e));
}
Run Code Online (Sandbox Code Playgroud)
我将 PropertyChangedEventArgs e 传递给 NotifyCollectionChangedEventArgs 的构造函数。
根据 Intellisense,第二个构造函数采用两个参数:NotifyCollectionChangedAction 和一个名为“changedObject”的对象,该对象被描述为“受更改影响的项目”。
所以我想我可以在 CollectionChangedEventHandler 中获取该对象并检查 PropertyName,但是哦!惊喜!NotifyCollectionChangedEventArgs 不公开“ChangedObject”属性(我可以看到 Action、NewItems、OldItems、NewStartingIndex、OldStartingIndex)。
关于如何实现这一目标有什么想法吗?顺便问一下,使用稍后无法访问的对象构造 NotifyCollectionChangedEventArgs 有什么用处?
c# observablecollection inotifycollectionchanged inotifypropertychanged
我有以下情况:
查询:
我向UserControl添加了一个名为"SelectedCustomerItems"的依赖属性,我希望它返回一个List <CustomerModel>(仅用于IsSelected = true)
此UserControl放在另一个窗口上
但我没有通过此依赖项属性获取SelectedCustomer项.断点没有打到Get {}请建议....